home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / tcl / Tcl.man < prev    next >
Encoding:
Text File  |  1992-11-01  |  170.7 KB  |  3,433 lines

  1.  
  2.  
  3.  
  4. Tcl                   C Library Procedures                    Tcl
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NNAAMMEE
  11.      Tcl - overview of tool command language facilities
  12. _________________________________________________________________
  13.  
  14.  
  15. IINNTTRROODDUUCCTTIIOONN
  16.      Tcl stands for ``tool command language'' and  is  pronounced
  17.      ``tickle.''  It  is  actually  two  things: a language and a
  18.      library.  First, Tcl is a simple textual language,  intended
  19.      primarily  for issuing commands to interactive programs such
  20.      as text editors, debuggers, illustrators,  and  shells.   It
  21.      has  a  simple syntax and is also programmable, so Tcl users
  22.      can write command procedures to provide more  powerful  com-
  23.      mands than those in the built-in set.
  24.  
  25.      Second, Tcl is a library package that  can  be  embedded  in
  26.      application  programs.  The Tcl library consists of a parser
  27.      for the Tcl language, routines to implement the Tcl built-in
  28.      commands,  and  procedures  that  allow  each application to
  29.      extend Tcl with additional commands specific to that  appli-
  30.      cation.   The application program generates Tcl commands and
  31.      passes them to the Tcl parser for execution.   Commands  may
  32.      be  generated by reading characters from an input source, or
  33.      by  associating  command  strings  with  elements   of   the
  34.      application's user interface, such as menu entries, buttons,
  35.      or keystrokes.  When the Tcl library  receives  commands  it
  36.      parses them into component fields and executes built-in com-
  37.      mands directly.  For commands implemented  by  the  applica-
  38.      tion,  Tcl calls back to the application to execute the com-
  39.      mands.  In many cases commands will invoke recursive invoca-
  40.      tions  of  the  Tcl  interpreter  by  passing  in additional
  41.      strings to execute (procedures, looping commands, and condi-
  42.      tional commands all work in this way).
  43.  
  44.      An application program gains three advantages by  using  Tcl
  45.      for  its  command  language.  First, Tcl provides a standard
  46.      syntax:  once users know Tcl, they will  be  able  to  issue
  47.      commands  easily  to any Tcl-based application.  Second, Tcl
  48.      provides programmability.  All a Tcl application needs to do
  49.      is  to  implement  a few application-specific low-level com-
  50.      mands.  Tcl provides many utility commands  plus  a  general
  51.      programming  interface  for building up complex command pro-
  52.      cedures.  By using Tcl, applications need  not  re-implement
  53.      these features.  Third, Tcl can be used as a common language  |
  54.      for communicating between  applications.   Inter-application  |
  55.      communication is not built into the Tcl core described here,  |
  56.      but various add-on libraries, such as the Tk toolkit,  allow  |
  57.      applications to issue commands to each other.  This makes it  |
  58.      possible for applications to  work  together  in  much  more  |
  59.      powerful ways than was previously possible.
  60.  
  61.  
  62.  
  63. Sprite v1.0                                                     1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Tcl                   C Library Procedures                    Tcl
  71.  
  72.  
  73.  
  74.      This manual page focuses primarily on the Tcl language.   It
  75.      describes the language syntax and the built-in commands that
  76.      will be available in any  application  based  on  Tcl.   The
  77.      individual  library  procedures are described in more detail
  78.      in separate manual pages, one per procedure.
  79.  
  80.  
  81. IINNTTEERRPPRREETTEERRSS
  82.      The central data structure in Tcl is an interpreter (C  type
  83.      ``Tcl_Interp'').   An  interpreter consists of a set of com-
  84.      mand bindings, a set of variable values,  and  a  few  other
  85.      miscellaneous  pieces  of state.  Each Tcl command is inter-
  86.      preted in the context of  a  particular  interpreter.   Some
  87.      Tcl-based  applications  will maintain multiple interpreters
  88.      simultaneously, each associated with a different  widget  or
  89.      portion  of  the  application.   Interpreters are relatively
  90.      lightweight structures.  They can  be  created  and  deleted
  91.      quickly,  so application programmers should feel free to use
  92.      multiple interpreters if that  simplifies  the  application.
  93.      Eventually Tcl will provide a mechanism for sending Tcl com-
  94.      mands and results back and forth between interpreters,  even
  95.      if the interpreters are managed by different processes.
  96.  
  97.  
  98. DDAATTAA TTYYPPEESS
  99.      Tcl supports only one type of data:  strings.  All commands,
  100.      all  arguments  to  commands,  all  command results, and all
  101.      variable values are strings.  Where commands require numeric
  102.      arguments  or  return  numeric  results,  the  arguments and
  103.      results are passed as strings.  Many commands  expect  their
  104.      string arguments to have certain formats, but this interpre-
  105.      tation is up to the individual commands.  For example, argu-
  106.      ments  often contain Tcl command strings, which may get exe-
  107.      cuted as part of the commands.  The easiest  way  to  under-
  108.      stand  the Tcl interpreter is to remember that everything is
  109.      just an operation on a string.  In many cases Tcl constructs
  110.      will  look  similar to more structured constructs from other
  111.      languages.  However, the Tcl constructs are  not  structured
  112.      at  all; they are just strings of characters, and this gives
  113.      them a different behavior than the structures they may  look
  114.      like.
  115.  
  116.      Although the exact interpretation of a Tcl string depends on
  117.      who  is  doing  the  interpretation,  there are three common
  118.      forms that strings take:  commands, expressions, and  lists.
  119.      The  major  sections below discuss these three forms in more
  120.      detail.
  121.  
  122.  
  123. BBAASSIICC CCOOMMMMAANNDD SSYYNNTTAAXX
  124.      The Tcl language has syntactic similarities to both the Unix
  125.      shells and Lisp.  However, the interpretation of commands is
  126.  
  127.  
  128.  
  129. Sprite v1.0                                                     2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. Tcl                   C Library Procedures                    Tcl
  137.  
  138.  
  139.  
  140.      different in Tcl than in either of those other two  systems.
  141.      A  Tcl  command  string  consists  of  one  or more commands
  142.      separated by newline characters or semi-colons.   Each  com-
  143.      mand  consists  of a collection of fields separated by white
  144.      space (spaces or tabs).  The first field must be the name of
  145.      a  command, and the additional fields, if any, are arguments
  146.      that will be passed to that command.  For example, the  com-
  147.      mand
  148.  
  149.           sseett aa 2222
  150.      has three fields:  the first, sseett, is the name of a Tcl com-
  151.      mand,  and  the  last two, aa and 2222, will be passed as argu-
  152.      ments to the sseett command.  The command name may refer either
  153.      to  a  built-in Tcl command, an application-specific command
  154.      bound in with the library procedure TTccll__CCrreeaatteeCCoommmmaanndd, or  a
  155.      command  procedure  defined  with the pprroocc built-in command.
  156.      Arguments are passed literally as text strings.   Individual
  157.      commands  may  interpret  those  strings in any fashion they
  158.      wish.  The sseett command, for example, will  treat  its  first
  159.      argument  as  the name of a variable and its second argument
  160.      as a string value to assign to  that  variable.   For  other
  161.      commands  arguments  may  be interpreted as integers, lists,
  162.      file names, or Tcl commands.
  163.  
  164.      Command names should normally be typed completely  (e.g.  no  |
  165.      abbreviations).   However,  if  the  Tcl  interpreter cannot  |
  166.      locate a command it invokes a special command named  uunnkknnoowwnn  |
  167.      which  attempts to find or create the command.  For example,  |
  168.      at many sites uunnkknnoowwnn will  search  through  library  direc-  |
  169.      tories  for  the desired command and create it as a Tcl pro-  |
  170.      cedure if it is found.  The uunnkknnoowwnn command  often  provides  |
  171.      automatic  completion  of  abbreviated commands, but usually  |
  172.      only for commands that were typed interactively.  It's prob-  |
  173.      ably  a bad idea to use abbreviations in command scripts and  |
  174.      other forms that will be re-used over time:  changes to  the  |
  175.      command  set  may  cause  abbreviations to become ambiguous,  |
  176.      resulting in scripts that no longer work.
  177.  
  178.  
  179. CCOOMMMMEENNTTSS
  180.      If the first non-blank character in a  command  is  ##,  then
  181.      everything  from the ## up through the next newline character
  182.      is treated as a comment  and  ignored.   When  comments  are
  183.      embedded  inside  nested  commands  (e.g. fields enclosed in
  184.      braces) they must  have  properly-matched  braces  (this  is
  185.      necessary  because  when Tcl parses the top-level command it
  186.      doesn't yet know that the nested field will  be  used  as  a
  187.      command so it cannot process the nested comment character as
  188.      a comment).
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Sprite v1.0                                                     3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. Tcl                   C Library Procedures                    Tcl
  203.  
  204.  
  205.  
  206. GGRROOUUPPIINNGG AARRGGUUMMEENNTTSS WWIITTHH DDOOUUBBLLEE--QQUUOOTTEESS
  207.      Normally each argument field ends at the next  white  space,
  208.      but  double-quotes  may  be  used  to  create arguments with
  209.      embedded space.  If an argument field begins with a  double-
  210.      quote,  then  the  argument  isn't terminated by white space
  211.      (including newlines) or a semi-colon (see below for informa-
  212.      tion  on  semi-colons);  instead it ends at the next double-
  213.      quote character.  The double-quotes are not included in  the
  214.      resulting argument.  For example, the command
  215.  
  216.           sseett aa ""TThhiiss iiss aa ssiinnggllee aarrgguummeenntt""
  217.      will pass two arguments to sseett:  aa  and  TThhiiss  iiss  aa  ssiinnggllee
  218.      aarrgguummeenntt.    Within  double-quotes,  command  substitutions,
  219.      variable substitutions, and  backslash  substitutions  still
  220.      occur, as described below.  If the first character of a com-
  221.      mand field is not a quote, then quotes  receive  no  special
  222.      interpretation in the parsing of that field.
  223.  
  224.  
  225. GGRROOUUPPIINNGG AARRGGUUMMEENNTTSS WWIITTHH BBRRAACCEESS
  226.      Curly braces may also be used for grouping arguments.   They
  227.      are  similar  to  quotes except for two differences.  First,
  228.      they nest; this makes them easier  to  use  for  complicated
  229.      arguments like nested Tcl command strings.  Second, the sub-
  230.      stitutions described  below  for  commands,  variables,  and
  231.      backslashes do _n_o_t occur in arguments enclosed in braces, so
  232.      braces can be used to prevent substitutions where  they  are
  233.      undesirable.  If an argument field begins with a left brace,
  234.      then the argument ends at the  matching  right  brace.   Tcl
  235.      will  strip  off  the outermost layer of braces and pass the
  236.      information between the braces to the  command  without  any
  237.      further modification.  For example, in the command
  238.  
  239.           sseett aa {{xxyyzz aa {{bb cc dd}}}}
  240.      the sseett command will receive two arguments: aa and xxyyzz aa {{bb cc
  241.      dd}}.
  242.  
  243.      When braces or quotes are in effect, the matching  brace  or
  244.      quote  need not be on the same line as the starting quote or
  245.      brace; in this case the newline  will  be  included  in  the
  246.      argument  field  along  with  any other characters up to the
  247.      matching brace or quote.   For  example,  the  eevvaall  command
  248.      takes  one argument, which is a command string; eevvaall invokes
  249.      the Tcl interpreter to execute the command string.  The com-
  250.      mand
  251.  
  252.           eevvaall {{
  253.                sseett aa 2222
  254.                sseett bb 3333
  255.           }}
  256.      will assign the value 2222 to aa and 3333 to bb.
  257.  
  258.  
  259.  
  260.  
  261. Sprite v1.0                                                     4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. Tcl                   C Library Procedures                    Tcl
  269.  
  270.  
  271.  
  272.      If the first character of a command  field  is  not  a  left
  273.      brace,  then neither left nor right braces in the field will
  274.      be treated specially (except as part of  variable  substitu-
  275.      tion; see below).
  276.  
  277.  
  278. CCOOMMMMAANNDD SSUUBBSSTTIITTUUTTIIOONN WWIITTHH BBRRAACCKKEETTSS
  279.      If an open bracket occurs in a field of a command, then com-
  280.      mand  substitution  occurs  (except  for  fields enclosed in
  281.      braces).  All of the text up to the matching  close  bracket
  282.      is  treated as a Tcl command and executed immediately.  Then
  283.      the result of that command is substituted for the  bracketed
  284.      text.  For example, consider the command
  285.  
  286.           sseett aa [[sseett bb]]
  287.      When the sseett command has only a single argument, it  is  the
  288.      name  of  a  variable  and  sseett returns the contents of that
  289.      variable.  In this case, if variable bb has  the  value  ffoooo,
  290.      then the command above is equivalent to the command
  291.  
  292.           sseett aa ffoooo
  293.      Brackets can be used in more complex ways.  For example,  if
  294.      the  variable bb has the value ffoooo and the variable cc has the
  295.      value ggoorrpp, then the command
  296.  
  297.           sseett aa xxyyzz[[sseett bb]]..[[sseett cc]]
  298.      is equivalent to the command
  299.  
  300.           sseett aa xxyyzzffoooo..ggoorrpp
  301.      A bracketed command may contain multiple commands  separated  |
  302.      by  newlines  or  semi-colons in the usual fashion.  In this  |
  303.      case the value of the last command is used for substitution.  |
  304.      For example, the command                                      |
  305.  
  306.           sseett aa xx[[sseett bb 2222                                         |
  307.           eexxpprr $$bb++22]]xx                                              |
  308.      is equivalent to the command                                  |
  309.  
  310.           sseett aa xx2244xx                                               |
  311.      If a field is enclosed in braces then the brackets  and  the
  312.      characters  between them are not interpreted specially; they
  313.      are passed through to the argument verbatim.
  314.  
  315.  
  316. VVAARRIIAABBLLEE SSUUBBSSTTIITTUUTTIIOONN WWIITTHH $$
  317.      The dollar sign ($$) may be used as a special shorthand  form
  318.      for  substituting variable values.  If $$ appears in an argu-
  319.      ment that isn't enclosed in braces then  variable  substitu-
  320.      tion  will  occur.   The  characters  after the $$, up to the
  321.      first character that isn't a number, letter, or  underscore,
  322.      are  taken  as  a variable name and the string value of that
  323.      variable is substituted  for  the  name.   For  example,  if  |
  324.  
  325.  
  326.  
  327. Sprite v1.0                                                     5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. Tcl                   C Library Procedures                    Tcl
  335.  
  336.  
  337.  
  338.      variable ffoooo has the value tteesstt, then the command             |
  339.  
  340.           sseett aa $$ffoooo..cc                                             |
  341.      is equivalent to the command                                  |
  342.  
  343.           sseett aa tteesstt..cc                                             |
  344.  
  345.      There are two special forms for variable  substitution.   If  |
  346.      the next character after the name of the variable is an open  |
  347.      parenthesis, then the variable is assumed  to  be  an  array  |
  348.      name, and all of the characters between the open parenthesis  |
  349.      and the next close parenthesis are taken as  an  index  into  |
  350.      the array.  Command substitutions and variable substitutions  |
  351.      are performed on the  information  between  the  parentheses  |
  352.      before it is used as an index.  For example, if the variable  |
  353.      xx is an array with one element named ffiirrsstt and value 8877  and  |
  354.      another element named 1144 and value mmoorree, then the command     |
  355.  
  356.           sseett aa xxyyzz$$xx((ffiirrsstt))zzyyxx                                    |
  357.      is equivalent to the command                                  |
  358.  
  359.           sseett aa xxyyzz8877zzyyxx                                           |
  360.      If the variable iinnddeexx has the value 1144, then the command      |
  361.  
  362.           sseett aa xxyyzz$$xx(($$iinnddeexx))zzyyxx                                   |
  363.      is equivalent to the command                                  |
  364.  
  365.           sseett aa xxyyzzmmoorreezzyyxx                                         |
  366.      For more information on arrays,  see  VARIABLES  AND  ARRAYS  |
  367.      below.                                                        |
  368.  
  369.      The second special form for variables occurs when the dollar  |
  370.      sign  is  followed by an open curly brace.  In this case the  |
  371.      variable name consists of all the characters up to the  next  |
  372.      curly  brace.   Array  references  are  not possible in this  |
  373.      form:  the name between braces is  assumed  to  refer  to  a  |
  374.      scalar variable.  For example, if variable ffoooo has the value  |
  375.      tteesstt, then the command                                        |
  376.  
  377.           sseett aa aabbcc$${{ffoooo}}bbaarr                                       |
  378.      is equivalent to the command                                  |
  379.  
  380.           sseett aa aabbcctteessttbbaarr                                         |
  381.      Variable substitution does not occur in arguments  that  are
  382.      enclosed  in  braces:  the dollar sign and variable name are
  383.      passed through to the argument verbatim.
  384.  
  385.      The dollar sign abbreviation is simply a shorthand form.  $$aa
  386.      is  completely  equivalent  to  [[sseett aa]]; it is provided as a
  387.      convenience to reduce typing.
  388.  
  389.  
  390.  
  391.  
  392.  
  393. Sprite v1.0                                                     6
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. Tcl                   C Library Procedures                    Tcl
  401.  
  402.  
  403.  
  404. SSEEPPAARRAATTIINNGG CCOOMMMMAANNDDSS WWIITTHH SSEEMMII--CCOOLLOONNSS
  405.      Normally, each command occupies one  line  (the  command  is
  406.      terminated  by  a  newline  character).  However, semi-colon
  407.      (``;'') is treated as a command separator character;  multi-
  408.      ple  commands  may  be placed on one line by separating them
  409.      with a semi-colon.  Semi-colons are not treated  as  command
  410.      separators  if  they  appear  within curly braces or double-
  411.      quotes.
  412.  
  413.  
  414. BBAACCKKSSLLAASSHH SSUUBBSSTTIITTUUTTIIOONN
  415.      Backslashes may be used to  insert  non-printing  characters
  416.      into  command  fields  and also to insert special characters
  417.      like braces and brackets  into  fields  without  them  being
  418.      interpreted  specially  as  described  above.  The backslash
  419.      sequences understood  by  the  Tcl  interpreter  are  listed
  420.      below.   In each case, the backslash sequence is replaced by
  421.      the given character:
  422.  
  423.      \\bb                  Backspace (0x8).
  424.  
  425.      \\ff                  Form feed (0xc).
  426.  
  427.      \\nn                  Newline (0xa).
  428.  
  429.      \\rr                  Carriage-return (0xd).
  430.  
  431.      \\tt                  Tab (0x9).
  432.  
  433.      \\vv                  Vertical tab (0xb).
  434.  
  435.      \\{{                  Left brace (``{'').
  436.  
  437.      \\}}                  Right brace (``}'').
  438.  
  439.      \\[[                  Open bracket (``['').
  440.  
  441.      \\]]                  Close bracket (``]'').
  442.  
  443.      \\$$                  Dollar sign (``$'').
  444.  
  445.      \\<<ssppaaccee>>            Space (`` ''): doesn't  terminate  argu-
  446.                          ment.
  447.  
  448.      \\;;                  Semi-colon: doesn't terminate command.
  449.  
  450.      \\""                  Double-quote.
  451.  
  452.      \\<<nneewwlliinnee>>          Nothing:  this joins two lines  together
  453.                          into  a  single  line.   This  backslash
  454.                          feature is unique in  that  it  will  be
  455.                          applied  even  when  the sequence occurs
  456.  
  457.  
  458.  
  459. Sprite v1.0                                                     7
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. Tcl                   C Library Procedures                    Tcl
  467.  
  468.  
  469.  
  470.                          within braces.
  471.  
  472.      \\\\                  Backslash (``\'').
  473.  
  474.      \\_d_d_d                The digits _d_d_d (one, two,  or  three  of
  475.                          them)  give the octal value of the char-
  476.                          acter.   Null  characters  may  not   be
  477.                          embedded  in  command  fields; if _d_d_d is
  478.                          zero  then  the  backslash  sequence  is
  479.                          ignored   (i.e.  it  maps  to  an  empty
  480.                          string).
  481.  
  482.      For example, in the command
  483.  
  484.           sseett aa \\{{xx\\[[\\ yyzz\\114411
  485.      the second argument to sseett will be ``{{xx[[ yyzzaa''.
  486.  
  487.      If a backslash is followed by something other  than  one  of
  488.      the options described above, then the backslash is transmit-
  489.      ted to the argument field without  any  special  processing,
  490.      and  the  Tcl  scanner  continues normal processing with the
  491.      next character.  For example, in the command
  492.  
  493.           sseett \\**aa \\\\\\{{ffoooo
  494.      The first argument to sseett will be \\**aa and the  second  argu-
  495.      ment will be \\{{ffoooo.
  496.  
  497.      If  an  argument  is  enclosed  in  braces,  then  backslash
  498.      sequences inside the argument are parsed but no substitution
  499.      occurs  (except  for  backslash-newline):    the   backslash
  500.      sequence  is  passed  through to the argument as is, without
  501.      making any special interpretation of the characters  in  the
  502.      backslash  sequence.   In particular, backslashed braces are
  503.      not counted in locating the matching right brace  that  ter-
  504.      minates the argument.  For example, in the command
  505.  
  506.           sseett aa {{\\{{aabbcc}}
  507.      the second argument to sseett will be \\{{aabbcc.
  508.  
  509.      This backslash mechanism is not sufficient to generate abso-
  510.      lutely  any argument structure; it only covers the most com-
  511.      mon cases.  To produce particularly complicated arguments it
  512.      is  probably  easiest  to  use the ffoorrmmaatt command along with
  513.      command substitution.
  514.  
  515.  
  516. CCOOMMMMAANNDD SSUUMMMMAARRYY
  517.      [1]  A command is just a string.
  518.  
  519.      [2]  Within a string commands are separated by  newlines  or
  520.           semi-colons (unless the newline or semi-colon is within
  521.           braces or brackets or is backslashed).
  522.  
  523.  
  524.  
  525. Sprite v1.0                                                     8
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. Tcl                   C Library Procedures                    Tcl
  533.  
  534.  
  535.  
  536.      [3]  A command consists of fields.  The first field  is  the
  537.           name of the command.  The other fields are strings that
  538.           are passed to that command as arguments.
  539.  
  540.      [4]  Fields are normally separated by white space.
  541.  
  542.      [5]  Double-quotes allow  white  space  and  semi-colons  to
  543.           appear within a single argument.  Command substitution,
  544.           variable substitution, and backslash substitution still
  545.           occur inside quotes.
  546.  
  547.      [6]  Braces defer interpretation of special characters.   If
  548.           a  field  begins with a left brace, then it consists of
  549.           everything between the  left  brace  and  the  matching
  550.           right  brace. The braces themselves are not included in
  551.           the argument.  No further processing  is  done  on  the
  552.           information  between  the braces except that backslash-
  553.           newline sequences are eliminated.
  554.  
  555.      [7]  If a field doesn't begin with a brace  then  backslash,
  556.           variable,  and  command  substitution  are  done on the
  557.           field.  Only a single level of processing is done:  the
  558.           results  of  one substitution are not scanned again for
  559.           further substitutions or any other  special  treatment.
  560.           Substitution  can  occur  on  any  field  of a command,
  561.           including the command name as well as the arguments.
  562.  
  563.      [8]  If the first non-blank character of a command is  a  ##,
  564.           everything  from  the  ## up through the next newline is
  565.           treated as a comment and ignored.
  566.  
  567.  
  568. EEXXPPRREESSSSIIOONNSS
  569.      The second major interpretation applied to strings in Tcl is  |
  570.      as  expressions.   Several  commands, such as eexxpprr, ffoorr, and  |
  571.      iiff, treat one or more of their arguments as expressions  and  |
  572.      call    the   Tcl   expression   processors   (TTccll__EExxpprrLLoonngg,  |
  573.      TTccll__EExxpprrBBoooolleeaann, etc.) to evaluate them.  The operators per-  |
  574.      mitted in Tcl expressions are a subset of the operators per-  |
  575.      mitted in C expressions, and they have the same meaning  and  |
  576.      precedence  as  the  corresponding C operators.  Expressions  |
  577.      almost always yield numeric results  (integer  or  floating-  |
  578.      point values).  For example, the expression                   |
  579.  
  580.           88..22 ++ 66                                                  |
  581.      evaluates to 14.2.  Tcl expressions differ  from  C  expres-  |
  582.      sions  in  the  way that operands are specified, and in that  |
  583.      Tcl expressions support non-numeric operands and string com-  |
  584.      parisons.                                                     |
  585.  
  586.      A Tcl expression consists  of  a  combination  of  operands,  |
  587.      operators, and parentheses.  White space may be used between  |
  588.  
  589.  
  590.  
  591. Sprite v1.0                                                     9
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. Tcl                   C Library Procedures                    Tcl
  599.  
  600.  
  601.  
  602.      the operands and operators and parentheses; it is ignored by  |
  603.      the  expression  processor.   Where  possible,  operands are  |
  604.      interpreted as integer values.  Integer values may be speci-  |
  605.      fied  in  decimal  (the normal case), in octal (if the first  |
  606.      character of the operand is 00), or in  hexadecimal  (if  the  |
  607.      first  two characters of the operand are 00xx).  If an operand  |
  608.      does not have one of the integer formats given  above,  then  |
  609.      it  is  treated as a floating-point number if that is possi-  |
  610.      ble.  Floating-point numbers may be specified in any of  the  |
  611.      ways  accepted  by an ANSI-compliant C compiler (except that  |
  612.      the ``f'', ``F'', ``l'', and ``L'' suffixes will not be per-  |
  613.      mitted in most installations).  For example, all of the fol-  |
  614.      lowing are valid  floating-point  numbers:   2.1,  3.,  6e4,  |
  615.      7.91e+16.  If no numeric interpretation is possible, then an  |
  616.      operand is left as a string  (and  only  a  limited  set  of  |
  617.      operators may be applied to it).                              |
  618.  
  619.      Operands may be specified in any of the following ways:       |
  620.  
  621.      [1]                                                                ||
  622.           As an numeric value, either integer or floating-point.   |
  623.  
  624.      [2]                                                                ||
  625.           As  a  Tcl  variable,  using  standard $$ notation.  The  |
  626.           variable's value will be used as the operand.            |
  627.  
  628.      [3]                                                                ||
  629.           As  a string enclosed in double-quotes.  The expression  |
  630.           parser will perform backslash,  variable,  and  command  |
  631.           substitutions  on  the  information between the quotes,  |
  632.           and use the resulting value as the operand               |
  633.  
  634.      [4]                                                                ||
  635.           As a string enclosed in braces.  The characters between  |
  636.           the open brace and matching close brace will be used as  |
  637.           the operand without any substitutions.                   |
  638.  
  639.      [5]                                                                ||
  640.           As  a  Tcl  command  enclosed in brackets.  The command  |
  641.           will be executed and its result will  be  used  as  the  |
  642.           operand.                                                 |
  643.  
  644.      Where  substitutions  occur  above   (e.g.   inside   quoted  |
  645.      strings),  they  are  performed by the expression processor.  |
  646.      However, an additional layer  of  substitution  may  already  |
  647.      have been performed by the command parser before the expres-  |
  648.      sion processor was called.  As discussed below, it  is  usu-  |
  649.      ally  best  to  enclose expressions in braces to prevent the  |
  650.      command parser from performing  substitutions  on  the  con-  |
  651.      tents.                                                        |
  652.  
  653.      For  some  examples  of  simple  expressions,  suppose   the  |
  654.  
  655.  
  656.  
  657. Sprite v1.0                                                    10
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. Tcl                   C Library Procedures                    Tcl
  665.  
  666.  
  667.  
  668.      variable  aa has the value 3 and the variable bb has the value  |
  669.      6.  Then the expression on the left  side  of  each  of  the  |
  670.      lines  below will evaluate to the value on the right side of  |
  671.      the line:                                                     |
  672.  
  673.           33..11 ++ $$aa                66..11                              |
  674.           22 ++ ""$$aa..$$bb""             55..66                              |
  675.           44**[[lllleennggtthh ""66 22""]]       88                                |
  676.           {{wwoorrdd oonnee}} << ""wwoorrdd $$aa""  00                                |
  677.  
  678.      The valid operators are listed below, grouped in  decreasing  |
  679.      order of precedence:                                          |
  680.  
  681.      --  ~~  !!                                                            ||
  682.                          Unary  minus, bit-wise NOT, logical NOT.  |
  683.                          None of these operands may be applied to  |
  684.                          string operands, and bit-wise NOT may be  |
  685.                          applied only to integers.                 |
  686.  
  687.      **  //  %%                                                            ||
  688.                          Multiply,  divide,  remainder.   None of  |
  689.                          these operands may be applied to  string  |
  690.                          operands,  and  remainder may be applied  |
  691.                          only to integers.                         |
  692.  
  693.      ++  --                                                               ||
  694.                          Add and subtract.  Valid for any numeric  |
  695.                          operands.                                 |
  696.  
  697.      <<<<  >>>>                                                             ||
  698.                          Left and right shift.  Valid for integer  |
  699.                          operands only.                            |
  700.  
  701.      <<  >>  <<==  >>==                                                       ||
  702.                          Boolean  less,  greater,  less  than  or  |
  703.                          equal, and greater than or equal.   Each  |
  704.                          operator  produces 1 if the condition is  |
  705.                          true, 0 otherwise.  These operators  may  |
  706.                          be applied to strings as well as numeric  |
  707.                          operands,  in  which  case  string  com-  |
  708.                          parison is used.                          |
  709.  
  710.      ====  !!==                                                             ||
  711.                          Boolean   equal  and  not  equal.   Each  |
  712.                          operator  produces  a  zero/one  result.  |
  713.                          Valid for all operand types.              |
  714.  
  715.      &&                                                                  ||
  716.                          Bit-wise   AND.    Valid   for   integer  |
  717.                          operands only.                            |
  718.  
  719.      ^^                                                                  ||
  720.  
  721.  
  722.  
  723. Sprite v1.0                                                    11
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. Tcl                   C Library Procedures                    Tcl
  731.  
  732.  
  733.  
  734.                          Bit-wise   exclusive   OR.    Valid  for  |
  735.                          integer operands only.                    |
  736.  
  737.      ||                                                                  ||
  738.                          Bit-wise OR.  Valid for integer operands  |
  739.                          only.                                     |
  740.  
  741.      &&&&                                                                 ||
  742.                          Logical  AND.   Produces  a  1 result if  |
  743.                          both operands are non-zero, 0 otherwise.  |
  744.                          Valid    for   numeric   operands   only  |
  745.                          (integers or floating-point).             |
  746.  
  747.      ||||                                                                 ||
  748.                          Logical OR.  Produces a 0 result if both  |
  749.                          operands are zero, 1  otherwise.   Valid  |
  750.                          for  numeric  operands only (integers or  |
  751.                          floating-point).                          |
  752.  
  753.      _x??_y::_z                                                              ||
  754.                          If-then-else,  as  in C.  If _x evaluates  |
  755.                          to non-zero,  then  the  result  is  the  |
  756.                          value of _y.  Otherwise the result is the  |
  757.                          value of _z.  The _x operand must  have  a  |
  758.                          numeric value.                            |
  759.  
  760.      See the C manual for more details on the results produced by  |
  761.      each  operator.   All of the binary operators group left-to-  |
  762.      right within the same precedence level.   For  example,  the  |
  763.      expression                                                    |
  764.  
  765.           44**22 << 77                                                  |
  766.      evaluates to 0.                                               |
  767.  
  768.      The &&&&, ||||, and ??:: operators have ``lazy evaluation'',  just  |
  769.      as in C, which means that operands are not evaluated if they  |
  770.      are not needed to determine the outcome.  For example, in     |
  771.  
  772.           $$vv ?? [[aa]] :: [[bb]]                                           |
  773.      only one of [[aa]] or [[bb]] will actually be evaluated, depending  |
  774.      on the value of $$vv.                                           |
  775.  
  776.      All internal computations involving integers are  done  with  |
  777.      the  C  type  _l_o_n_g,  and all internal computations involving  |
  778.      floating-point are done with the C type _d_o_u_b_l_e.   When  con-  |
  779.      verting  a  string  to  floating-point, exponent overflow is  |
  780.      detected and results in a  Tcl  error.   For  conversion  to  |
  781.      integer  from  string,  detection of overflow depends on the  |
  782.      behavior of some routines in the  local  C  library,  so  it  |
  783.      should be regarded as unreliable.  In any case, overflow and  |
  784.      underflow are generally not detected reliably for intermedi-  |
  785.      ate results.                                                  |
  786.  
  787.  
  788.  
  789. Sprite v1.0                                                    12
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. Tcl                   C Library Procedures                    Tcl
  797.  
  798.  
  799.  
  800.      Conversion  among  internal  representations  for   integer,  |
  801.      floating-point, and string operands is done automatically as  |
  802.      needed.  For  arithmetic  computations,  integers  are  used  |
  803.      until  some floating-point number is introduced, after which  |
  804.      floating-point is used.  For example,                         |
  805.  
  806.           55 // 44                                                    |
  807.      yields the result 1, while                                    |
  808.  
  809.           55 // 44..00                                                  |
  810.           55 // (( [[ssttrriinngg lleennggtthh ""aabbccdd""]] ++ 00..00 ))                     |
  811.      both yield the result 1.25.                                   |
  812.  
  813.      String values may be used  as  operands  of  the  comparison  |
  814.      operators,  although  the  expression  evaluator tries to do  |
  815.      comparisons as integer or floating-point when  it  can.   If  |
  816.      one  of  the  operands  of  a comparison is a string and the  |
  817.      other has a numeric value, the numeric operand is  converted  |
  818.      back to a string using the C _s_p_r_i_n_t_f format specifier %%dd for  |
  819.      integers and %%gg for floating-point values.  For example, the  |
  820.      expressions                                                   |
  821.  
  822.           ""00xx0033"" >> ""22""                                             |
  823.           ""00yy"" << ""00xx1122""                                            |
  824.      both evaluate to 1.  The  first  comparison  is  done  using  |
  825.      integer comparison, and the second is done using string com-  |
  826.      parison after the second operand is converted to the  string  |
  827.      ``18''.
  828.  
  829.      In general it is safest to enclose an expression  in  braces
  830.      when entering it in a command:  otherwise, if the expression
  831.      contains any white space then the Tcl interpreter will split
  832.      it among several arguments.  For example, the command
  833.  
  834.           eexxpprr $$aa ++ $$bb
  835.      results in three arguments being passed to eexxpprr:  $$aa, ++, and
  836.      $$bb.  In addition, if the expression isn't in braces then the
  837.      Tcl interpreter will perform variable and command  substitu-
  838.      tion  immediately  (it  will  happen  in  the command parser
  839.      rather than in the expression parser).  In  many  cases  the
  840.      expression  is  being passed to a command that will evaluate
  841.      the expression later (or even many times  if,  for  example,
  842.      the expression is to be used to decide when to exit a loop).
  843.      Usually the desired goal is to re-do the variable or command
  844.      substitutions  each time the expression is evaluated, rather
  845.      than once and for all at the beginning.   For  example,  the
  846.      command
  847.  
  848.           ffoorr {{sseett ii 11}} $$ii<<==1100 {{iinnccrr ii}} {{......}}*** WRONG ***
  849.      is probably intended to iterate over all values of ii from  1
  850.      to  10.   After  each iteration of the body of the loop, ffoorr
  851.      will pass its second argument to the expression evaluator to
  852.  
  853.  
  854.  
  855. Sprite v1.0                                                    13
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. Tcl                   C Library Procedures                    Tcl
  863.  
  864.  
  865.  
  866.      see  whether  or not to continue processing.  Unfortunately,
  867.      in this case the value of ii in the second argument  will  be
  868.      substituted once and for all when the ffoorr command is parsed.
  869.      If ii was 0 before the ffoorr command  was  invoked  then  ffoorr's
  870.      second  argument will be 00<<==1100 which will always evaluate to
  871.      1, even though ii's value eventually becomes greater than 10.
  872.      In  the  above case the loop will never terminate.  Instead,
  873.      the expression should be placed in braces:
  874.  
  875.           ffoorr {{sseett ii 11}} {{$$ii<<==1100}} {{iinnccrr ii}} {{......}}*** RIGHT ***
  876.      This causes the substitution of ii's value to be delayed;  it
  877.      will be re-done each time the expression is evaluated, which
  878.      is the desired result.
  879.  
  880.  
  881. LLIISSTTSS
  882.      The third major way that strings are interpreted in  Tcl  is
  883.      as  lists.   A list is just a string with a list-like struc-
  884.      ture consisting of fields separated  by  white  space.   For
  885.      example, the string
  886.  
  887.           AAll SSuuee AAnnnnee JJoohhnn
  888.      is a list with four elements or fields.  Lists have the same
  889.      basic  structure  as  command strings, except that a newline
  890.      character in a list is treated as  a  field  separator  just
  891.      like  space  or  tab.  Conventions for braces and quotes and
  892.      backslashes are the same for lists  as  for  commands.   For
  893.      example, the string
  894.  
  895.           aa bb\\ cc {{dd ee {{ff gg hh}}}}
  896.      is a list with three elements:  aa, bb cc, and dd  ee  {{ff  gg  hh}}.
  897.      Whenever an element is extracted from a list, the same rules
  898.      about braces and quotes and backslashes are applied  as  for
  899.      commands.   Thus in the example above when the third element
  900.      is extracted from the list, the result is
  901.  
  902.           dd ee {{ff gg hh}}
  903.      (when the field was extracted,  all  that  happened  was  to
  904.      strip off the outermost layer of braces).  Command substitu-
  905.      tion and variable substitution are never made on a list  (at
  906.      least,  not  by  the  list-processing commands; the list can
  907.      always be passed to the Tcl interpreter for evaluation).
  908.  
  909.      The Tcl commands ccoonnccaatt, ffoorreeaacchh, llaappppeenndd, lliinnddeexx,  lliinnsseerrtt,  |
  910.      lliisstt,  lllleennggtthh,  llrraannggee,  llrreeppllaaccee, llsseeaarrcchh, and llssoorrtt allow  |
  911.      you to build lists, extract elements from them, search them,
  912.      and perform other list-related functions.
  913.  
  914.  
  915. RREEGGUULLAARR EEXXPPRREESSSSIIOONNSS
  916.      Tcl provides two commands that support string matching using  |
  917.      eeggrreepp-style regular expressions: rreeggeexxpp and rreeggssuubb.  Regular  |
  918.  
  919.  
  920.  
  921. Sprite v1.0                                                    14
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. Tcl                   C Library Procedures                    Tcl
  929.  
  930.  
  931.  
  932.      expressions are implemented using Henry  Spencer's  package,  |
  933.      and  the  description of regular expressions below is copied  |
  934.      verbatim from his manual entry.                               |
  935.  
  936.      A regular expression is zero or more _b_r_a_n_c_h_e_s, separated  by  |
  937.      ``|''.    It  matches  anything  that  matches  one  of  the  |
  938.      branches.                                                     |
  939.  
  940.      A branch is zero or more _p_i_e_c_e_s, concatenated.  It matches a  |
  941.      match  for  the  first,  followed by a match for the second,  |
  942.      etc.                                                          |
  943.  
  944.      A piece is an _a_t_o_m possibly followed  by  ``*'',  ``+'',  or  |
  945.      ``?''.  An atom followed by ``*'' matches a sequence of 0 or  |
  946.      more matches of the atom.  An atom followed by ``+'' matches  |
  947.      a  sequence  of 1 or more matches of the atom.  An atom fol-  |
  948.      lowed by ``?'' matches a match of  the  atom,  or  the  null  |
  949.      string.                                                       |
  950.  
  951.      An atom is a regular expression in parentheses  (matching  a  |
  952.      match  for  the  regular  expression),  a _r_a_n_g_e (see below),  |
  953.      ``.'' (matching any single character), ``^''  (matching  the  |
  954.      null  string  at  the  beginning of the input string), ``$''  |
  955.      (matching the null string at the end of the input string), a  |
  956.      ``\''  followed by a single character (matching that charac-  |
  957.      ter), or a  single  character  with  no  other  significance  |
  958.      (matching that character).                                    |
  959.  
  960.      A _r_a_n_g_e is a sequence of characters enclosed in ``[]''.   It  |
  961.      normally matches any single character from the sequence.  If  |
  962.      the sequence begins with ``^'', it matches any single  char-  |
  963.      acter  _n_o_t from the rest of the sequence.  If two characters  |
  964.      in the sequence are separated by ``-'',  this  is  shorthand  |
  965.      for  the  full  list  of ASCII characters between them (e.g.  |
  966.      ``[0-9]'' matches any decimal digit).  To include a  literal  |
  967.      ``]''  in the sequence, make it the first character (follow-  |
  968.      ing a possible ``^'').  To include a literal ``-'', make  it  |
  969.      the first or last character.                                  |
  970.  
  971.      If a regular expression could match two different parts of a  |
  972.      string,  it  will  match  the one which begins earliest.  If  |
  973.      both begin in the same place but match different lengths, or  |
  974.      match  the same length in different ways, life gets messier,  |
  975.      as follows.                                                   |
  976.  
  977.      In general, the possibilities in a list of branches are con-  |
  978.      sidered in left-to-right order, the possibilities for ``*'',  |
  979.      ``+'', and ``?'' are considered longest-first,  nested  con-  |
  980.      structs  are  considered  from  the  outermost  in, and con-  |
  981.      catenated constructs  are  considered  leftmost-first.   The  |
  982.      match  that will be chosen is the one that uses the earliest  |
  983.      possibility in the first choice that has  to  be  made.   If  |
  984.  
  985.  
  986.  
  987. Sprite v1.0                                                    15
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. Tcl                   C Library Procedures                    Tcl
  995.  
  996.  
  997.  
  998.      there  is more than one choice, the next will be made in the  |
  999.      same manner (earliest possibility) subject to  the  decision  |
  1000.      on the first choice.  And so forth.                           |
  1001.  
  1002.      For example, ``(ab|a)b*c'' could match ``abc'' in one of two  |
  1003.      ways.   The  first choice is between ``ab'' and ``a''; since  |
  1004.      ``ab'' is earlier, and does lead  to  a  successful  overall  |
  1005.      match, it is chosen.  Since the ``b'' is already spoken for,  |
  1006.      the  ``b*''  must  match  its  last  possibility-the   empty  |
  1007.      string-since it must respect the earlier choice.              |
  1008.  
  1009.      In the particular case where no ``|''s are present and there  |
  1010.      is  only  one ``*'', ``+'', or ``?'', the net effect is that  |
  1011.      the longest possible match  will  be  chosen.   So  ``ab*'',  |
  1012.      presented with ``xabbbby'', will match ``abbbb''.  Note that  |
  1013.      if ``ab*'' is tried against  ``xabyabbbz'',  it  will  match  |
  1014.      ``ab''  just  after  ``x'', due to the begins-earliest rule.  |
  1015.      (In effect, the decision on where to start the match is  the  |
  1016.      first  choice  to  be  made,  hence  subsequent choices must  |
  1017.      respect it even if this leads them to less-preferred  alter-  |
  1018.      natives.)
  1019.  
  1020.  
  1021. CCOOMMMMAANNDD RREESSUULLTTSS
  1022.      Each command produces two results:  a  code  and  a  string.
  1023.      The  code  indicates  whether the command completed success-
  1024.      fully or not, and the string gives  additional  information.
  1025.      The valid codes are defined in tcl.h, and are:
  1026.  
  1027.           TTCCLL__OOKK              This is the normal return code, and
  1028.                               indicates  that  the  command  com-
  1029.                               pleted  successfully.   The  string
  1030.                               gives the command's return value.
  1031.  
  1032.           TTCCLL__EERRRROORR           Indicates that an  error  occurred;
  1033.                               the string gives a message describ-
  1034.                               ing the error.   In  addition,  the  |
  1035.                               global variable eerrrroorrIInnffoo will con-  |
  1036.                               tain   human-readable   information  |
  1037.                               describing  which commands and pro-  |
  1038.                               cedures were  being  executed  when  |
  1039.                               the  error occurred, and the global  |
  1040.                               variable  eerrrroorrCCooddee  will   contain  |
  1041.                               machine-readable  details about the  |
  1042.                               error, if they are available.   See  |
  1043.                               the   section   BUILT-IN  VARIABLES  |
  1044.                               below for more information.
  1045.  
  1046.           TTCCLL__RREETTUURRNN          Indicates that the  rreettuurrnn  command
  1047.                               has  been  invoked,  and  that  the
  1048.                               current  procedure  (or   top-level
  1049.                               command  or  ssoouurrccee command) should
  1050.  
  1051.  
  1052.  
  1053. Sprite v1.0                                                    16
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. Tcl                   C Library Procedures                    Tcl
  1061.  
  1062.  
  1063.  
  1064.                               return  immediately.   The   string
  1065.                               gives the return value for the pro-
  1066.                               cedure or command.
  1067.  
  1068.           TTCCLL__BBRREEAAKK           Indicates that  the  bbrreeaakk  command
  1069.                               has  been invoked, so the innermost
  1070.                               loop should abort immediately.  The
  1071.                               string should always be empty.
  1072.  
  1073.           TTCCLL__CCOONNTTIINNUUEE        Indicates that the ccoonnttiinnuuee command
  1074.                               has  been invoked, so the innermost
  1075.                               loop  should  go  on  to  the  next
  1076.                               iteration.    The   string   should
  1077.                               always be empty.
  1078.      Tcl programmers do not normally need to think  about  return
  1079.      codes,  since TCL_OK is almost always returned.  If anything
  1080.      else is returned by a  command,  then  the  Tcl  interpreter
  1081.      immediately  stops  processing  commands  and returns to its
  1082.      caller.  If there are several nested invocations of the  Tcl
  1083.      interpreter  in progress, then each nested command will usu-
  1084.      ally return the error to its caller,  until  eventually  the
  1085.      error  is  reported  to the top-level application code.  The
  1086.      application will then display  the  error  message  for  the
  1087.      user.
  1088.  
  1089.      In a few cases, some commands will handle certain  ``error''
  1090.      conditions  themselves  and  not  return  them upwards.  For
  1091.      example, the ffoorr command checks for the TCL_BREAK  code;  if
  1092.      it occurs, then ffoorr stops executing the body of the loop and
  1093.      returns TCL_OK to its caller.  The ffoorr command also  handles
  1094.      TCL_CONTINUE  codes  and  the  procedure interpreter handles
  1095.      TCL_RETURN codes.  The ccaattcchh command allows Tcl programs  to
  1096.      catch  errors  and  handle  them  without  aborting  command
  1097.      interpretation any further.
  1098.  
  1099.  
  1100. PPRROOCCEEDDUURREESS
  1101.      Tcl allows you to extend the command interface  by  defining
  1102.      procedures.   A  Tcl  procedure can be invoked just like any
  1103.      other Tcl command (it has a name and it receives one or more
  1104.      arguments).   The  only  difference is that its body isn't a
  1105.      piece of C code linked into the program; it is a string con-
  1106.      taining  one  or more other Tcl commands.  See the pprroocc com-
  1107.      mand for information on how to define  procedures  and  what
  1108.      happens when they are invoked.
  1109.  
  1110.  
  1111. VVAARRIIAABBLLEESS -- SSCCAALLAARRSS AANNDD AARRRRAAYYSS
  1112.      Tcl allows the definition of variables and the use of  their  |
  1113.      values either through $$-style variable substitution, the sseett  |
  1114.      command, or a few other mechanisms.  Variables need  not  be  |
  1115.      declared:  a new variable will automatically be created each  |
  1116.  
  1117.  
  1118.  
  1119. Sprite v1.0                                                    17
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. Tcl                   C Library Procedures                    Tcl
  1127.  
  1128.  
  1129.  
  1130.      time a new variable name is used.                             |
  1131.  
  1132.      Tcl supports two types of variables:  scalars and arrays.  A  |
  1133.      scalar  variable  has a single value, whereas an array vari-  |
  1134.      able can have any number  of  elements,  each  with  a  name  |
  1135.      (called  its  ``index'')  and a value.  Array indexes may be  |
  1136.      arbitrary strings; they need not  be  numeric.   Parentheses  |
  1137.      are used refer to array elements in Tcl commands.  For exam-  |
  1138.      ple, the command                                              |
  1139.  
  1140.           sseett xx((ffiirrsstt)) 4444                                          |
  1141.      will modify the element of xx whose index is  ffiirrsstt  so  that  |
  1142.      its  new  value  is 4444.  Two-dimensional arrays can be simu-  |
  1143.      lated in Tcl by using indexes  that  contain  multiple  con-  |
  1144.      catenated values.  For example, the commands                  |
  1145.  
  1146.           sseett aa((22,,33)) 11                                             |
  1147.           sseett aa((33,,66)) 22                                             |
  1148.      set the elements of aa whose indexes are 22,,33 and 33,,66.          |
  1149.  
  1150.      In general, array elements may be used anywhere in Tcl  that  |
  1151.      scalar variables may be used.  If an array is defined with a  |
  1152.      particular name, then there may not  be  a  scalar  variable  |
  1153.      with  the  same name.  Similarly, if there is a scalar vari-  |
  1154.      able with a particular name then it is not possible to  make  |
  1155.      array references to the variable.  To convert a scalar vari-  |
  1156.      able to an array or vice versa, remove the existing variable  |
  1157.      with the uunnsseett command.                                       |
  1158.  
  1159.      The aarrrraayy command provides several features for dealing with  |
  1160.      arrays,  such  as  querying the names of all the elements of  |
  1161.      the array and searching through the array one element  at  a  |
  1162.      time.
  1163.  
  1164.      Variables may be either global or local.  If a variable name
  1165.      is  used  when  a  procedure  isn't  being executed, then it
  1166.      automatically refers to a global variable.   Variable  names
  1167.      used  within  a  procedure normally refer to local variables
  1168.      associated with that invocation  of  the  procedure.   Local
  1169.      variables  are deleted whenever a procedure exits.  The gglloo--
  1170.      bbaall command may be used to request that a name  refer  to  a
  1171.      global  variable  for  the duration of the current procedure
  1172.      (this is somewhat analogous to eexxtteerrnn in C).
  1173.  
  1174.  
  1175. BBUUIILLTT--IINN CCOOMMMMAANNDDSS
  1176.      The Tcl library provides the  following  built-in  commands,
  1177.      which  will  be  available in any application using Tcl.  In
  1178.      addition to these built-in commands, there may be additional
  1179.      commands  defined by each application, plus commands defined
  1180.      as Tcl  procedures.   In  the  command  syntax  descriptions
  1181.      below, words in boldface are literals that you type verbatim
  1182.  
  1183.  
  1184.  
  1185. Sprite v1.0                                                    18
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. Tcl                   C Library Procedures                    Tcl
  1193.  
  1194.  
  1195.  
  1196.      to Tcl.  Words in italics are meta-symbols;  they  serve  as
  1197.      names  for  any  of  a  range  of  values that you can type.
  1198.      Optional arguments or groups of arguments are  indicated  by
  1199.      enclosing  them in question-marks.  Ellipses (``...'') indi-
  1200.      cate that any number of additional arguments  or  groups  of
  1201.      arguments  may  appear,  in the same format as the preceding
  1202.      argument(s).
  1203.  
  1204.      aappppeenndd _v_a_r_N_a_m_e _v_a_l_u_e ?_v_a_l_u_e _v_a_l_u_e ...?
  1205.           Append all of the _v_a_l_u_e arguments to the current  value  |
  1206.           of  variable  _v_a_r_N_a_m_e.  If _v_a_r_N_a_m_e doesn't exist, it is  |
  1207.           given a value equal to the  concatenation  of  all  the  |
  1208.           _v_a_l_u_e  arguments.   This  command provides an efficient  |
  1209.           way to build  up  long  variables  incrementally.   For  |
  1210.           example,  ``aappppeenndd  aa  $$bb'' is much more efficient than  |
  1211.           ``sseett aa $$aa$$bb'' if $$aa is long.
  1212.  
  1213.      aarrrraayy _o_p_t_i_o_n _a_r_r_a_y_N_a_m_e ?_a_r_g _a_r_g ...?
  1214.           This command performs one of several operations on  the  |
  1215.           variable  given  by  _a_r_r_a_y_N_a_m_e.   _A_r_r_a_y_N_a_m_e must be the  |
  1216.           name of an existing array variable.  The  _o_p_t_i_o_n  argu-  |
  1217.           ment  determines what action is carried out by the com-  |
  1218.           mand.  The legal _o_p_t_i_o_n_s  (which  may  be  abbreviated)  |
  1219.           are:                                                     |
  1220.  
  1221.           aarrrraayy aannyymmoorree _a_r_r_a_y_N_a_m_e _s_e_a_r_c_h_I_d                              ||
  1222.                Returns  1  if there are any more elements left to  |
  1223.                be processed in an array search, 0 if all elements  |
  1224.                have  already  been  returned.  _S_e_a_r_c_h_I_d indicates  |
  1225.                which search on _a_r_r_a_y_N_a_m_e to check, and must  have  |
  1226.                been  the  return value from a previous invocation  |
  1227.                of aarrrraayy ssttaarrttsseeaarrcchh.  This option is particularly  |
  1228.                useful  if  an  array has an element with an empty  |
  1229.                name, since the return value from  aarrrraayy  nneexxtteellee--  |
  1230.                mmeenntt  won't  indicate  whether the search has been  |
  1231.                completed.                                          |
  1232.  
  1233.           aarrrraayy ddoonneesseeaarrcchh _a_r_r_a_y_N_a_m_e _s_e_a_r_c_h_I_d                           ||
  1234.                This  command  terminates an array search and des-  |
  1235.                troys all the state associated with  that  search.  |
  1236.                _S_e_a_r_c_h_I_d  indicates  which  search on _a_r_r_a_y_N_a_m_e to  |
  1237.                destroy, and must have been the return value  from  |
  1238.                a   previous   invocation  of  aarrrraayy  ssttaarrttsseeaarrcchh.  |
  1239.                Returns an empty string.                            |
  1240.  
  1241.           aarrrraayy nnaammeess _a_r_r_a_y_N_a_m_e                                         ||
  1242.                Returns  a list containing the names of all of the  |
  1243.                elements in the array.  If there are  no  elements  |
  1244.                in the array then an empty string is returned.      |
  1245.  
  1246.           aarrrraayy nneexxtteelleemmeenntt _a_r_r_a_y_N_a_m_e _s_e_a_r_c_h_I_d                          ||
  1247.                Returns the name of the next element in _a_r_r_a_y_N_a_m_e,  |
  1248.  
  1249.  
  1250.  
  1251. Sprite v1.0                                                    19
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. Tcl                   C Library Procedures                    Tcl
  1259.  
  1260.  
  1261.  
  1262.                or an empty string if all  elements  of  _a_r_r_a_y_N_a_m_e  |
  1263.                have  already  been  returned in this search.  The  |
  1264.                _s_e_a_r_c_h_I_d argument identifies the search, and  must  |
  1265.                have been the return value of an aarrrraayy ssttaarrttsseeaarrcchh  |
  1266.                command.  Warning:  if elements are  added  to  or  |
  1267.                deleted  from  the  array,  then  all searches are  |
  1268.                automatically  terminated   just   as   if   aarrrraayy  |
  1269.                ddoonneesseeaarrcchh had been invoked; this will cause aarrrraayy  |
  1270.                nneexxtteelleemmeenntt operations to fail for those searches.  |
  1271.  
  1272.           aarrrraayy ssiizzee _a_r_r_a_y_N_a_m_e                                          ||
  1273.                Returns a decimal string giving the number of ele-  |
  1274.                ments in the array.                                 |
  1275.  
  1276.           aarrrraayy ssttaarrttsseeaarrcchh _a_r_r_a_y_N_a_m_e                                   ||
  1277.                This  command  initializes  an  element-by-element  |
  1278.                search through the array given by _a_r_r_a_y_N_a_m_e,  such  |
  1279.                that  invocations of the aarrrraayy nneexxtteelleemmeenntt command  |
  1280.                will return the names of the  individual  elements  |
  1281.                in the array.  When the search has been completed,  |
  1282.                the aarrrraayy ddoonneesseeaarrcchh command  should  be  invoked.  |
  1283.                The  return value is a search identifier that must  |
  1284.                be used in aarrrraayy nneexxtteelleemmeenntt and aarrrraayy  ddoonneesseeaarrcchh  |
  1285.                commands; it allows multiple searches to be under-  |
  1286.                way simultaneously for the same array.
  1287.  
  1288.      bbrreeaakk
  1289.           This command may be invoked only inside the body  of  a
  1290.           loop  command  such  as  ffoorr  or  ffoorreeaacchh or wwhhiillee.  It
  1291.           returns a TCL_BREAK code to signal the  innermost  con-
  1292.           taining loop command to return immediately.
  1293.  
  1294.      ccaassee _s_t_r_i_n_g ?iinn? _p_a_t_L_i_s_t _b_o_d_y ?_p_a_t_L_i_s_t _b_o_d_y ...?
  1295.  
  1296.      ccaassee _s_t_r_i_n_g ?iinn? {_p_a_t_L_i_s_t _b_o_d_y ?_p_a_t_L_i_s_t _b_o_d_y ...?}
  1297.           Match _s_t_r_i_n_g against each of the _p_a_t_L_i_s_t  arguments  in
  1298.           order.   If  one  matches,  then evaluate the following
  1299.           _b_o_d_y argument by passing  it  recursively  to  the  Tcl
  1300.           interpreter,  and return the result of that evaluation.
  1301.           Each _p_a_t_L_i_s_t argument consists of a single  pattern  or
  1302.           list  of patterns.  Each pattern may contain any of the
  1303.           wild-cards described under ssttrriinngg mmaattcchh.  If a  _p_a_t_L_i_s_t
  1304.           argument  is  ddeeffaauulltt,  the  corresponding body will be
  1305.           evaluated if no _p_a_t_L_i_s_t matches _s_t_r_i_n_g.  If no  _p_a_t_L_i_s_t
  1306.           argument  matches  _s_t_r_i_n_g and no default is given, then
  1307.           the ccaassee command returns an empty string.
  1308.  
  1309.           Two syntaxes are provided.  The first uses  a  separate
  1310.           argument  for  each  of the patterns and commands; this
  1311.           form is convenient if substitutions are desired on some
  1312.           of  the  patterns  or commands.  The second form places  |
  1313.           all of the patterns and commands together into a single  |
  1314.  
  1315.  
  1316.  
  1317. Sprite v1.0                                                    20
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. Tcl                   C Library Procedures                    Tcl
  1325.  
  1326.  
  1327.  
  1328.           argument; the argument must have proper list structure,  |
  1329.           with the elements of the list being  the  patterns  and  |
  1330.           commands.   The  second form makes it easy to construct  |
  1331.           multi-line case commands, since the braces  around  the  |
  1332.           whole  list  make it unnecessary to include a backslash  |
  1333.           at the end of each line.  Since the  _p_a_t_L_i_s_t  arguments  |
  1334.           are  in  braces in the second form, no command or vari-  |
  1335.           able substitutions are performed on them;   this  makes  |
  1336.           the  behavior  of  the  second  form different than the  |
  1337.           first form in some cases.                                |
  1338.  
  1339.           Below are some examples of ccaassee commands:                |
  1340.  
  1341.                ccaassee aabbcc iinn {{aa bb}} {{ffoorrmmaatt 11}} ddeeffaauulltt {{ffoorrmmaatt 22}} aa** {{ffoorrmmaatt 33}}|
  1342.           will return 33,                                           |
  1343.  
  1344.                ccaassee aa iinn {{                                         |
  1345.                  {{aa bb}} {{ffoorrmmaatt 11}}                                  |
  1346.                  ddeeffaauulltt {{ffoorrmmaatt 22}}                                |
  1347.                  aa** {{ffoorrmmaatt 33}}                                     |
  1348.                }}                                                   |
  1349.           will return 11, and                                       |
  1350.  
  1351.                ccaassee xxyyzz {{                                          |
  1352.                  {{aa bb}}                                             |
  1353.                    {{ffoorrmmaatt 11}}                                      |
  1354.                  ddeeffaauulltt                                           |
  1355.                    {{ffoorrmmaatt 22}}                                      |
  1356.                  aa**                                                |
  1357.                    {{ffoorrmmaatt 33}}                                      |
  1358.                }}                                                   |
  1359.           will return 22.
  1360.  
  1361.      ccaattcchh _c_o_m_m_a_n_d ?_v_a_r_N_a_m_e?
  1362.           The ccaattcchh command may be used to  prevent  errors  from
  1363.           aborting  command  interpretation.  CCaattcchh calls the Tcl
  1364.           interpreter recursively to execute _c_o_m_m_a_n_d, and  always
  1365.           returns  a  TCL_OK  code, regardless of any errors that
  1366.           might occur while executing _c_o_m_m_a_n_d.  The return  value
  1367.           from ccaattcchh is a decimal string giving the code returned
  1368.           by the Tcl interpreter after executing  _c_o_m_m_a_n_d.   This
  1369.           will  be 00 (TCL_OK) if there were no errors in _c_o_m_m_a_n_d;
  1370.           otherwise it will have a non-zero  value  corresponding
  1371.           to  one  of the exceptional return codes (see tcl.h for
  1372.           the definitions of code values).  If the _v_a_r_N_a_m_e  argu-
  1373.           ment  is  given,  then it gives the name of a variable;
  1374.           ccaattcchh will set the value of the variable to the  string
  1375.           returned from _c_o_m_m_a_n_d (either a result or an error mes-
  1376.           sage).
  1377.  
  1378.      ccdd ?_d_i_r_N_a_m_e?
  1379.           Change the current working directory to _d_i_r_N_a_m_e, or  to  |
  1380.  
  1381.  
  1382.  
  1383. Sprite v1.0                                                    21
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. Tcl                   C Library Procedures                    Tcl
  1391.  
  1392.  
  1393.  
  1394.           the  home  directory (as specified in the HOME environ-  |
  1395.           ment variable) if _d_i_r_N_a_m_e is  not  given.   If  _d_i_r_N_a_m_e  |
  1396.           starts  with  a  tilde, then tilde-expansion is done as  |
  1397.           described for TTccll__TTiillddeeSSuubbsstt.  Returns an empty string.  |
  1398.           This command can potentially be disruptive to an appli-  |
  1399.           cation, so it may be removed in some applications.       |
  1400.  
  1401.      cclloossee _f_i_l_e_I_d                                                       ||
  1402.           Closes  the  file  given by _f_i_l_e_I_d.  _F_i_l_e_I_d must be the  |
  1403.           return value from a previous  invocation  of  the  ooppeenn  |
  1404.           command;  after  this  command,  it  should not be used  |
  1405.           anymore.   If  _f_i_l_e_I_d  refers  to  a  command  pipeline  |
  1406.           instead of a file, then cclloossee waits for the children to  |
  1407.           complete.  The normal result  of  this  command  is  an  |
  1408.           empty  string,  but  errors  are  returned if there are  |
  1409.           problems in closing the file or waiting for children to  |
  1410.           complete.
  1411.  
  1412.      ccoonnccaatt _a_r_g ?_a_r_g ...?
  1413.           This command treats each argument as a  list  and  con-
  1414.           catenates  them  into  a  single  list.  It permits any
  1415.           number of arguments.  For example, the command
  1416.  
  1417.                ccoonnccaatt aa bb {{cc dd ee}} {{ff {{gg hh}}}}
  1418.           will return
  1419.  
  1420.                aa bb cc dd ee ff {{gg hh}}
  1421.           as its result.
  1422.  
  1423.      ccoonnttiinnuuee
  1424.           This command may be invoked only inside the body  of  a
  1425.           loop  command  such  as  ffoorr  or  ffoorreeaacchh or wwhhiillee.  It
  1426.           returns a  TCL_CONTINUE code to  signal  the  innermost
  1427.           containing  loop  command  to skip the remainder of the
  1428.           loop's body but continue with the next iteration of the
  1429.           loop.
  1430.  
  1431.      eeooff _f_i_l_e_I_d
  1432.           Returns 1 if an end-of-file condition has  occurred  on  |
  1433.           _f_i_l_e_I_d,  0 otherwise.  _F_i_l_e_I_d must have been the return  |
  1434.           value from a previous call to ooppeenn, or it may be ssttddiinn,  |
  1435.           ssttddoouutt,  or  ssttddeerrrr to refer to one of the standard I/O  |
  1436.           channels.
  1437.  
  1438.      eerrrroorr _m_e_s_s_a_g_e ?_i_n_f_o? ?_c_o_d_e?
  1439.           Returns  a  TCL_ERROR  code,   which   causes   command
  1440.           interpretation to be unwound.  _M_e_s_s_a_g_e is a string that
  1441.           is returned to the application to  indicate  what  went
  1442.           wrong.
  1443.  
  1444.           If the _i_n_f_o argument is provided and is  non-empty,  it
  1445.           is  used  to  initialize the global variable eerrrroorrIInnffoo.
  1446.  
  1447.  
  1448.  
  1449. Sprite v1.0                                                    22
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. Tcl                   C Library Procedures                    Tcl
  1457.  
  1458.  
  1459.  
  1460.           eerrrroorrIInnffoo is used to accumulate a stack trace  of  what
  1461.           was  in progress when an error occurred; as nested com-
  1462.           mands unwind, the Tcl interpreter adds  information  to
  1463.           eerrrroorrIInnffoo.  If the _i_n_f_o argument is present, it is used
  1464.           to initialize eerrrroorrIInnffoo  and  the  first  increment  of
  1465.           unwind  information will not be added by the Tcl inter-
  1466.           preter.  In other words,  the  command  containing  the
  1467.           eerrrroorr  command  will  not  appear  in eerrrroorrIInnffoo; in its
  1468.           place will be _i_n_f_o.  This feature  is  most  useful  in
  1469.           conjunction  with  the ccaattcchh command: if a caught error
  1470.           cannot be handled successfully, _i_n_f_o  can  be  used  to
  1471.           return  a  stack trace reflecting the original point of
  1472.           occurrence of the error:
  1473.  
  1474.                ccaattcchh {{......}} eerrrrMMssgg
  1475.                sseett ssaavveeddIInnffoo $$eerrrroorrIInnffoo
  1476.                ......
  1477.                eerrrroorr $$eerrrrMMssgg $$ssaavveeddIInnffoo
  1478.  
  1479.           If the _c_o_d_e argument is  present,  then  its  value  is  |
  1480.           stored in the eerrrroorrCCooddee global variable.  This variable  |
  1481.           is intended to hold a machine-readable  description  of  |
  1482.           the error in cases where such information is available;  |
  1483.           see the section BUILT-IN VARIABLES below  for  informa-  |
  1484.           tion  on  the  proper  format for the variable.  If the  |
  1485.           _c_o_d_e  argument  is  not  present,  then  eerrrroorrCCooddee   is  |
  1486.           automatically  reset to ``NONE'' by the Tcl interpreter  |
  1487.           as part of processing the error generated by  the  com-  |
  1488.           mand.
  1489.  
  1490.      eevvaall _a_r_g ?_a_r_g ...?
  1491.           EEvvaall  takes  one  or  more  arguments,  which  together
  1492.           comprise  a  Tcl command (or collection of Tcl commands
  1493.           separated by newlines in the  usual  way).   EEvvaall  con-
  1494.           catenates  all its arguments in the same fashion as the
  1495.           ccoonnccaatt command, passes the concatenated string  to  the
  1496.           Tcl  interpreter recursively, and returns the result of
  1497.           that evaluation (or any error generated by it).
  1498.  
  1499.      eexxeecc _a_r_g ?_a_r_g ...?
  1500.           This command treats its arguments as the  specification  |
  1501.           of  one  or  more  UNIX  commands  to  execute  as sub-  |
  1502.           processes.  The commands take the form  of  a  standard  |
  1503.           shell  pipeline;  ``|''  arguments separate commands in  |
  1504.           the pipeline and cause standard output of the preceding  |
  1505.           command  to  be  piped  into standard input of the next  |
  1506.           command.                                                 |
  1507.  
  1508.           Under normal conditions the result of the eexxeecc  command  |
  1509.           consists  of  the  standard output produced by the last  |
  1510.           command in the pipeline.  If any of the commands in the  |
  1511.           pipeline  exit  abnormally  or are killed or suspended,  |
  1512.  
  1513.  
  1514.  
  1515. Sprite v1.0                                                    23
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. Tcl                   C Library Procedures                    Tcl
  1523.  
  1524.  
  1525.  
  1526.           then eexxeecc will return an error and  the  error  message  |
  1527.           will  include  the  pipeline's output followed by error  |
  1528.           messages  describing  the  abnormal  terminations;  the  |
  1529.           eerrrroorrCCooddee  variable will contain additional information  |
  1530.           about the last abnormal  termination  encountered.   If  |
  1531.           any  of the commands writes to its standard error file,  |
  1532.           then eexxeecc will return an error, and the  error  message  |
  1533.           will  include  the  pipeline's output, followed by mes-  |
  1534.           sages about abnormal terminations (if any), followed by  |
  1535.           the standard error output.                               |
  1536.  
  1537.           If the last character of the result or error message is  |
  1538.           a  newline  then  that  character  is  deleted from the  |
  1539.           result or error message for consistency with normal Tcl  |
  1540.           return values.                                           |
  1541.  
  1542.           If an _a_r_g has the value ``>'' then the following  argu-  |
  1543.           ment  is  taken  as the name of a file and the standard  |
  1544.           output  of  the  last  command  in  the   pipeline   is  |
  1545.           redirected  to  the  file.  In this situation eexxeecc will  |
  1546.           normally return an empty string.                         |
  1547.  
  1548.           If an _a_r_g has the value ``<'' then the following  argu-  |
  1549.           ment is taken as the name of a file to use for standard  |
  1550.           input to the first command  in  the  pipeline.   If  an  |
  1551.           argument  has the value ``<<'' then the following argu-  |
  1552.           ment is taken as an immediate value to be passed to the  |
  1553.           first  command as standard input.  If there is no ``<''  |
  1554.           or ``<<'' argument then  the  standard  input  for  the  |
  1555.           first  command  in  the  pipeline  is  taken  from  the  |
  1556.           application's current standard input.                    |
  1557.  
  1558.           If the last _a_r_g is ``&'' then the command will be  exe-  |
  1559.           cuted  in background.  In this case the standard output  |
  1560.           from the last command in the pipeline will  go  to  the  |
  1561.           application's  standard output unless redirected in the  |
  1562.           command, and error output from all the commands in  the  |
  1563.           pipeline  will  go  to the application's standard error  |
  1564.           file.                                                    |
  1565.  
  1566.           Each _a_r_g becomes one word for  a  command,  except  for  |
  1567.           ``|'',  ``<'',  ``<<'', ``>'', and ``&'' arguments, and  |
  1568.           the arguments that follow  ``<'',  ``<<'',  and  ``>''.  |
  1569.           The  first word in each command is taken as the command  |
  1570.           name; tilde-substitution is performed on  it,  and  the  |
  1571.           directories   in  the  PATH  environment  variable  are  |
  1572.           searched for an  executable  by  the  given  name.   No  |
  1573.           ``glob''  expansion  or  other shell-like substitutions  |
  1574.           are performed on the arguments to commands.              |
  1575.  
  1576.      eexxiitt ?returnCode?                                                  ||
  1577.           Terminate  the  process,  returning  _r_e_t_u_r_n_C_o_d_e  to the  |
  1578.  
  1579.  
  1580.  
  1581. Sprite v1.0                                                    24
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. Tcl                   C Library Procedures                    Tcl
  1589.  
  1590.  
  1591.  
  1592.           parent as the exit status.  If _r_e_t_u_r_n_C_o_d_e isn't  speci-  |
  1593.           fied then it defaults to 0.
  1594.  
  1595.      eexxpprr _a_r_g
  1596.           Calls the expression processor  to  evaluate  _a_r_g,  and
  1597.           returns  the  result  as  a  string.   See  the section
  1598.           EXPRESSIONS above.
  1599.  
  1600.      ffiillee _o_p_t_i_o_n _n_a_m_e ?_a_r_g _a_r_g ...?
  1601.           Operate on a file or a file name.  _N_a_m_e is the name  of  |
  1602.           a file; if it starts with a tilde, then tilde substitu-  |
  1603.           tion is done before  executing  the  command  (see  the  |
  1604.           manual  entry  for TTccll__TTiillddeeSSuubbsstt for details).  _O_p_t_i_o_n  |
  1605.           indicates what to do with the file  name.   Any  unique  |
  1606.           abbreviation  for  _o_p_t_i_o_n  is  acceptable.   The  valid  |
  1607.           options are:                                             |
  1608.  
  1609.           ffiillee aattiimmee _n_a_m_e                                               ||
  1610.                Return  a  decimal string giving the time at which  |
  1611.                file _n_a_m_e was last accessed.  The time is measured  |
  1612.                in  the  standard  UNIX  fashion as seconds from a  |
  1613.                fixed starting time (often January 1,  1970).   If  |
  1614.                the  file  doesn't exist or its access time cannot  |
  1615.                be queried then an error is generated.              |
  1616.  
  1617.           ffiillee ddiirrnnaammee _n_a_m_e                                             ||
  1618.                Return all of the characters in _n_a_m_e up to but not  |
  1619.                including the last slash character.  If there  are  |
  1620.                no slashes in _n_a_m_e then return ``.''.  If the last  |
  1621.                slash in _n_a_m_e is its first character, then  return  |
  1622.                ``/''.                                              |
  1623.  
  1624.           ffiillee eexxeeccuuttaabbllee _n_a_m_e                                          ||
  1625.                Return 11 if file _n_a_m_e is executable by the current  |
  1626.                user, 00 otherwise.                                  |
  1627.  
  1628.           ffiillee eexxiissttss _n_a_m_e                                              ||
  1629.                Return  11 if file _n_a_m_e exists and the current user  |
  1630.                has search privileges for the directories  leading  |
  1631.                to it, 00 otherwise.                                 |
  1632.  
  1633.           ffiillee eexxtteennssiioonn _n_a_m_e                                           ||
  1634.                Return  all  of  the  characters in _n_a_m_e after and  |
  1635.                including the last dot in _n_a_m_e.  If  there  is  no  |
  1636.                dot in _n_a_m_e then return the empty string.           |
  1637.  
  1638.           ffiillee iissddiirreeccttoorryy _n_a_m_e                                         ||
  1639.                Return 11 if file _n_a_m_e is a directory, 00 otherwise.  |
  1640.  
  1641.           ffiillee iissffiillee _n_a_m_e                                              ||
  1642.                Return  11 if file _n_a_m_e is a regular file, 00 other-  |
  1643.                wise.                                               |
  1644.  
  1645.  
  1646.  
  1647. Sprite v1.0                                                    25
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. Tcl                   C Library Procedures                    Tcl
  1655.  
  1656.  
  1657.  
  1658.           ffiillee llssttaatt _n_a_m_e _v_a_r_N_a_m_e                                       ||
  1659.                Same  as  ssttaatt  option (see below) except uses the  |
  1660.                _l_s_t_a_t kernel call instead  of  _s_t_a_t.   This  means  |
  1661.                that  if _n_a_m_e refers to a symbolic link the infor-  |
  1662.                mation returned in _v_a_r_N_a_m_e is for the link  rather  |
  1663.                than the file it refers to.  On systems that don't  |
  1664.                support symbolic links this option behaves exactly  |
  1665.                the same as the ssttaatt option.                        |
  1666.  
  1667.           ffiillee mmttiimmee _n_a_m_e                                               ||
  1668.                Return  a  decimal string giving the time at which  |
  1669.                file _n_a_m_e was last modified.  The time is measured  |
  1670.                in  the  standard  UNIX  fashion as seconds from a  |
  1671.                fixed starting time (often January 1,  1970).   If  |
  1672.                the file doesn't exist or its modified time cannot  |
  1673.                be queried then an error is generated.              |
  1674.  
  1675.           ffiillee oowwnneedd _n_a_m_e                                               ||
  1676.                Return  11  if  file  _n_a_m_e  is owned by the current  |
  1677.                user, 00 otherwise.                                  |
  1678.  
  1679.           ffiillee rreeaaddaabbllee _n_a_m_e                                            ||
  1680.                Return  11  if file _n_a_m_e is readable by the current  |
  1681.                user, 00 otherwise.                                  |
  1682.  
  1683.           ffiillee rreeaaddlliinnkk _n_a_m_e                                            ||
  1684.                Returns  the  value  of the symbolic link given by  |
  1685.                _n_a_m_e (i.e. the name of the file it points to).  If  |
  1686.                _n_a_m_e  isn't a symbolic link or its value cannot be  |
  1687.                read, then an error is returned.  On systems  that  |
  1688.                don't  support symbolic links this option is unde-  |
  1689.                fined.                                              |
  1690.  
  1691.           ffiillee rroooottnnaammee _n_a_m_e                                            ||
  1692.                Return all of the characters in _n_a_m_e up to but not  |
  1693.                including the last ``.'' character  in  the  name.  |
  1694.                If _n_a_m_e doesn't contain a dot, then return _n_a_m_e.    |
  1695.  
  1696.           ffiillee ssiizzee _n_a_m_e                                                ||
  1697.                Return  a  decimal  string giving the size of file  |
  1698.                _n_a_m_e in bytes.  If the file doesn't exist  or  its  |
  1699.                size cannot be queried then an error is generated.  |
  1700.  
  1701.           ffiillee ssttaatt  _n_a_m_e _v_a_r_N_a_m_e                                       ||
  1702.                Invoke  the  ssttaatt kernel call on _n_a_m_e, and use the  |
  1703.                variable given  by  _v_a_r_N_a_m_e  to  hold  information  |
  1704.                returned from the kernel call.  _V_a_r_N_a_m_e is treated  |
  1705.                as an array variable, and the  following  elements  |
  1706.                of  that variable are set: aattiimmee, ccttiimmee, ddeevv, ggiidd,  |
  1707.                iinnoo, mmooddee, mmttiimmee, nnlliinnkk, ssiizzee,  ttyyppee,  uuiidd.   Each  |
  1708.                element  except  ttyyppee is a decimal string with the  |
  1709.                value of the corresponding  field  from  the  ssttaatt  |
  1710.  
  1711.  
  1712.  
  1713. Sprite v1.0                                                    26
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. Tcl                   C Library Procedures                    Tcl
  1721.  
  1722.  
  1723.  
  1724.                return  structure;  see  the manual entry for ssttaatt  |
  1725.                for details on the meanings of  the  values.   The  |
  1726.                ttyyppee  element  gives  the  type of the file in the  |
  1727.                same form returned by the command ffiillee ttyyppee.  This  |
  1728.                command returns an empty string.                    |
  1729.  
  1730.           ffiillee ttaaiill _n_a_m_e                                                ||
  1731.                Return  all  of  the  characters in _n_a_m_e after the  |
  1732.                last slash.  If  _n_a_m_e  contains  no  slashes  then  |
  1733.                return _n_a_m_e.                                        |
  1734.  
  1735.           ffiillee ttyyppee _n_a_m_e                                                ||
  1736.                Returns  a  string  giving  the type of file _n_a_m_e,  |
  1737.                which will be  one  of  ffiillee,  ddiirreeccttoorryy,  cchhaarraacc--  |
  1738.                tteerrSSppeecciiaall, bblloocckkSSppeecciiaall, ffiiffoo, lliinnkk, or ssoocckkeett.    |
  1739.  
  1740.           ffiillee wwrriittaabbllee _n_a_m_e                                            ||
  1741.                Return  11  if file _n_a_m_e is writable by the current  |
  1742.                user, 00 otherwise.                                  |
  1743.  
  1744.                                                                         ||
  1745.           The  ffiillee  commands  that  return 0/1 results are often  |
  1746.           used in conditional or looping commands, for example:    |
  1747.  
  1748.                iiff {{!![[ffiillee eexxiissttss ffoooo]]}} tthheenn {{eerrrroorr {{bbaadd ffiillee nnaammee}}}} eellssee {{......}}|
  1749.  
  1750.      fflluusshh _f_i_l_e_I_d
  1751.           Flushes any output that has been buffered  for  _f_i_l_e_I_d.  |
  1752.           _F_i_l_e_I_d  must have been the return value from a previous  |
  1753.           call to ooppeenn, or it may be ssttddoouutt or ssttddeerrrr  to  access  |
  1754.           one  of  the  standard  I/O streams; it must refer to a  |
  1755.           file that was opened for writing.  This command returns  |
  1756.           an empty string.
  1757.  
  1758.      ffoorr _s_t_a_r_t _t_e_s_t _n_e_x_t _b_o_d_y
  1759.           FFoorr is a looping command, similar in structure to the C
  1760.           ffoorr  statement.   The  _s_t_a_r_t,  _n_e_x_t, and _b_o_d_y arguments
  1761.           must be Tcl command strings, and _t_e_s_t is an  expression
  1762.           string.   The  ffoorr command first invokes the Tcl inter-
  1763.           preter to execute _s_t_a_r_t.  Then it repeatedly  evaluates
  1764.           _t_e_s_t  as  an  expression;  if the result is non-zero it
  1765.           invokes the Tcl interpreter on _b_o_d_y, then  invokes  the
  1766.           Tcl  interpreter  on  _n_e_x_t, then repeats the loop.  The
  1767.           command terminates when _t_e_s_t evaluates to 0.  If a ccoonn--
  1768.           ttiinnuuee command is invoked within _b_o_d_y then any remaining
  1769.           commands in the current execution of _b_o_d_y are  skipped;
  1770.           processing continues by invoking the Tcl interpreter on
  1771.           _n_e_x_t, then evaluating _t_e_s_t, and so on.  If a bbrreeaakk com-
  1772.           mand  is invoked within _b_o_d_y or _n_e_x_t, then the ffoorr com-
  1773.           mand will return immediately.  The operation  of  bbrreeaakk
  1774.           and  ccoonnttiinnuuee  are  similar to the corresponding state-
  1775.           ments in C.  FFoorr returns an empty string.
  1776.  
  1777.  
  1778.  
  1779. Sprite v1.0                                                    27
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. Tcl                   C Library Procedures                    Tcl
  1787.  
  1788.  
  1789.  
  1790.      ffoorreeaacchh _v_a_r_n_a_m_e _l_i_s_t _b_o_d_y
  1791.           In this command, _v_a_r_n_a_m_e is the  name  of  a  variable,
  1792.           _l_i_s_t is a list of values to assign to _v_a_r_n_a_m_e, and _b_o_d_y
  1793.           is a collection of Tcl commands.   For  each  field  in
  1794.           _l_i_s_t (in order from left to right), ffoorreeaacchh assigns the
  1795.           contents of the field to _v_a_r_n_a_m_e (as if the lliinnddeexx com-
  1796.           mand  had  been  used to extract the field), then calls
  1797.           the Tcl interpreter to execute  _b_o_d_y.   The  bbrreeaakk  and
  1798.           ccoonnttiinnuuee  statements  may  be invoked inside _b_o_d_y, with
  1799.           the same effect as in the ffoorr command.  FFoorreeaacchh returns
  1800.           an empty string.
  1801.  
  1802.      ffoorrmmaatt _f_o_r_m_a_t_S_t_r_i_n_g ?_a_r_g _a_r_g ...?
  1803.           This command generates a formatted string in  the  same
  1804.           way  as the C sspprriinnttff procedure (it uses sspprriinnttff in its
  1805.           implementation).  _F_o_r_m_a_t_S_t_r_i_n_g indicates how to  format
  1806.           the result, using %% fields as in sspprriinnttff, and the addi-
  1807.           tional arguments, if any, provide values to be  substi-
  1808.           tuted  into the result.  All of the sspprriinnttff options are
  1809.           valid; see the sspprriinnttff man page for details.  Each  _a_r_g
  1810.           must  match  the expected type from the %% field in _f_o_r_-
  1811.           _m_a_t_S_t_r_i_n_g; the ffoorrmmaatt command converts each argument to
  1812.           the correct type (floating, integer, etc.) before pass-
  1813.           ing it to sspprriinnttff for  formatting.   The  only  unusual
  1814.           conversion is for %%cc; in this case the argument must be
  1815.           a decimal string, which will then be converted  to  the
  1816.           corresponding   ASCII  character  value.   FFoorrmmaatt  does
  1817.           backslash substitution on its _f_o_r_m_a_t_S_t_r_i_n_g argument, so
  1818.           backslash  sequences  in  _f_o_r_m_a_t_S_t_r_i_n_g  will be handled
  1819.           correctly even if  the  argument  is  in  braces.   The
  1820.           return value from ffoorrmmaatt is the formatted string.
  1821.  
  1822.      ggeettss _f_i_l_e_I_d ?_v_a_r_N_a_m_e?
  1823.           Reads the next line from the file given by  _f_i_l_e_I_d  and  |
  1824.           discards the terminating newline character.  If _v_a_r_N_a_m_e  |
  1825.           is specified, then the line is placed in  the  variable  |
  1826.           by  that  name  and  the return value is a count of the  |
  1827.           number of characters read (not including the  newline).  |
  1828.           If  the  end  of the file is reached before reading any  |
  1829.           characters then -1 is returned and _v_a_r_N_a_m_e is set to an  |
  1830.           empty  string.   If  _v_a_r_N_a_m_e  is not specified then the  |
  1831.           return value will be the line (minus the newline  char-  |
  1832.           acter)  or  an  empty  string if the end of the file is  |
  1833.           reached before reading any characters.  An empty string  |
  1834.           will  also be returned if a line contains no characters  |
  1835.           except the newline, so eeooff  may  have  to  be  used  to  |
  1836.           determine  what really happened.  If the last character  |
  1837.           in the file is  not  a  newline  character,  then  ggeettss  |
  1838.           behaves  as if there were an additional newline charac-  |
  1839.           ter at the end of the file.  _F_i_l_e_I_d must  be  ssttddiinn  or  |
  1840.           the  return value from a previous call to ooppeenn; it must  |
  1841.           refer to a file that was opened for reading.
  1842.  
  1843.  
  1844.  
  1845. Sprite v1.0                                                    28
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. Tcl                   C Library Procedures                    Tcl
  1853.  
  1854.  
  1855.  
  1856.      gglloobb ?--nnooccoommppllaaiinn? _f_i_l_e_n_a_m_e ?_f_i_l_e_n_a_m_e ...?
  1857.           This command  performs  filename  globbing,  using  csh
  1858.           rules.   The  returned  value  from gglloobb is the list of
  1859.           expanded filenames.  If --nnooccoommppllaaiinn is specified as the  |
  1860.           first  argument  then  an  empty  list may be returned;  |
  1861.           otherwise an error is returned if the expanded list  is  |
  1862.           empty.   The  --nnooccoommppllaaiinn  argument  must  be  provided  |
  1863.           exactly: an abbreviation will not be accepted.
  1864.  
  1865.      gglloobbaall _v_a_r_n_a_m_e ?_v_a_r_n_a_m_e ...?
  1866.           This command is ignored unless a Tcl procedure is being
  1867.           interpreted.    If  so,  then  it  declares  the  given
  1868.           _v_a_r_n_a_m_e's to be  global  variables  rather  than  local
  1869.           ones.   For  the duration of the current procedure (and
  1870.           only while executing in  the  current  procedure),  any
  1871.           reference  to  any  of  the _v_a_r_n_a_m_es will be bound to a
  1872.           global variable instead of a local one.
  1873.  
  1874.      hhiissttoorryy ?_o_p_t_i_o_n? ?_a_r_g _a_r_g ...?
  1875.           Note:  this command may not be available  in  all  Tcl-
  1876.           based applications.  Typically, only those that receive
  1877.           command input in a typescript form  will  support  his-
  1878.           tory.   The  hhiissttoorryy  command  performs  one of several
  1879.           operations  related   to   recently-executed   commands
  1880.           recorded  in  a  history  list.  Each of these recorded
  1881.           commands is referred to as an ``event''.  When specify-
  1882.           ing  an  event  to  the  hhiissttoorryy command, the following
  1883.           forms may be used:
  1884.  
  1885.           [1]  A number:  if positive, it  refers  to  the  event
  1886.                with that number (all events are numbered starting
  1887.                at 1).  If the number is negative, it  selects  an
  1888.                event  relative to the current event (--11 refers to
  1889.                the previous event, --22 to the one before that, and
  1890.                so on).
  1891.  
  1892.           [2]  A string:  selects  the  most  recent  event  that
  1893.                matches  the  string.   An  event is considered to
  1894.                match the string either if the string is the  same
  1895.                as  the  first  characters of the event, or if the
  1896.                string matches the  event  in  the  sense  of  the
  1897.                ssttrriinngg mmaattcchh command.
  1898.  
  1899.           The hhiissttoorryy command  can  take  any  of  the  following
  1900.           forms:
  1901.  
  1902.           hhiissttoorryy
  1903.                Same as hhiissttoorryy iinnffoo, described below.              |
  1904.  
  1905.           hhiissttoorryy aadddd _c_o_m_m_a_n_d ?eexxeecc?
  1906.                Add the _c_o_m_m_a_n_d argument to the history list as  a
  1907.                new  event.  If eexxeecc is specified (or abbreviated)
  1908.  
  1909.  
  1910.  
  1911. Sprite v1.0                                                    29
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. Tcl                   C Library Procedures                    Tcl
  1919.  
  1920.  
  1921.  
  1922.                then the command is also executed and  its  result
  1923.                is  returned.   If  eexxeecc  isn't  specified then an
  1924.                empty string is returned as result.
  1925.  
  1926.           hhiissttoorryy cchhaannggee _n_e_w_V_a_l_u_e ?_e_v_e_n_t?
  1927.                Replace the  value  recorded  for  an  event  with
  1928.                _n_e_w_V_a_l_u_e.   _E_v_e_n_t  specifies the event to replace,
  1929.                and defaults to the _c_u_r_r_e_n_t event (not event  --11).
  1930.                This  command is intended for use in commands that
  1931.                implement new forms of  history  substitution  and
  1932.                wish  to  replace the current event (which invokes
  1933.                the substitution) with the command created through
  1934.                substitution.    The  return  value  is  an  empty
  1935.                string.
  1936.  
  1937.           hhiissttoorryy eevveenntt ?_e_v_e_n_t?
  1938.                Returns the value of the  event  given  by  _e_v_e_n_t.
  1939.                _E_v_e_n_t defaults to --11.  This command causes history
  1940.                revision to occur: see below for details.
  1941.  
  1942.           hhiissttoorryy iinnffoo ?_c_o_u_n_t?
  1943.                Returns a formatted string (intended for humans to
  1944.                read)  giving  the  event  number and contents for
  1945.                each of the events in the history list except  the
  1946.                current  event.   If  _c_o_u_n_t is specified then only
  1947.                the most recent _c_o_u_n_t events are returned.
  1948.  
  1949.           hhiissttoorryy kkeeeepp _c_o_u_n_t
  1950.                This command may be used to change the size of the
  1951.                history  list  to  _c_o_u_n_t  events.   Initially,  20
  1952.                events are retained in  the  history  list.   This
  1953.                command returns an empty string.
  1954.  
  1955.           hhiissttoorryy nneexxttiidd
  1956.                Returns  the  number  of  the  next  event  to  be
  1957.                recorded  in  the  history list.  It is useful for
  1958.                things like printing the event number in  command-
  1959.                line prompts.
  1960.  
  1961.           hhiissttoorryy rreeddoo ?_e_v_e_n_t?
  1962.                Re-execute the  command  indicated  by  _e_v_e_n_t  and
  1963.                return  its  result.   _E_v_e_n_t defaults to --11.  This
  1964.                command results in history  revision:   see  below
  1965.                for details.
  1966.  
  1967.           hhiissttoorryy ssuubbssttiittuuttee _o_l_d _n_e_w ?_e_v_e_n_t?
  1968.                Retrieve  the  command  given  by  _e_v_e_n_t  (--11   by
  1969.                default), replace any occurrences of _o_l_d by _n_e_w in
  1970.                the command (only  simple  character  equality  is
  1971.                supported;  no  wild cards), execute the resulting
  1972.                command, and return the result of that  execution.
  1973.                This  command  results  in  history revision:  see
  1974.  
  1975.  
  1976.  
  1977. Sprite v1.0                                                    30
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. Tcl                   C Library Procedures                    Tcl
  1985.  
  1986.  
  1987.  
  1988.                below for details.
  1989.  
  1990.           hhiissttoorryy wwoorrddss _s_e_l_e_c_t_o_r ?_e_v_e_n_t?
  1991.                Retrieve from the command given by  _e_v_e_n_t  (--11  by
  1992.                default)  the  words given by _s_e_l_e_c_t_o_r, and return
  1993.                those words in a string separated by spaces.   The
  1994.                sseelleeccttoorr  argument  has  three  forms.  If it is a
  1995.                single number then it selects the  word  given  by
  1996.                that  number  (00  for  the command name, 11 for its
  1997.                first argument, and so on).  If it consists of two
  1998.                numbers  separated  by a dash, then it selects all
  1999.                the arguments between those two.  Otherwise sseelleecc--
  2000.                ttoorr  is  treated  as a pattern; all words matching
  2001.                that pattern (in the sense of  ssttrriinngg  mmaattcchh)  are
  2002.                returned.   In  the numeric forms $$ may be used to
  2003.                select the last word of a command.   For  example,
  2004.                suppose  the  most  recent  command in the history
  2005.                list is
  2006.  
  2007.                     ffoorrmmaatt  {{%%ss iiss %%dd yyeeaarrss oolldd}} AAlliiccee [[eexxpprr $$aaggeeIInnMMoonntthhss//1122]]
  2008.                Below are some history commands  and  the  results
  2009.                they would produce:
  2010.  
  2011.                     Command_______          Result______
  2012.  
  2013.                     hhiissttoorryy wwoorrddss $$ [[eexxpprr $$aaggeeIInnMMoonntthhss//1122]]
  2014.                     hhiissttoorryy wwoorrddss 11--22{{%%ss iiss %%dd yyeeaarrss  oolldd}} AAlliiccee
  2015.                     hhiissttoorryy wwoorrddss **aa**oo**{{%%ss iiss %%dd yyeeaarrss oolldd}} [[eexxpprr $$aaggeeIInnMMoonntthhss//1122]]
  2016.                HHiissttoorryy wwoorrddss results in  history  revision:   see
  2017.                below for details.
  2018.           The history options eevveenntt, rreeddoo, ssuubbssttiittuuttee, and  wwoorrddss
  2019.           result  in  ``history  revision''.   When  one of these
  2020.           options is invoked then the current event  is  modified
  2021.           to  eliminate  the  history command and replace it with
  2022.           the result of the history command.  For  example,  sup-
  2023.           pose  that  the most recent command in the history list
  2024.           is
  2025.  
  2026.                sseett aa [[eexxpprr $$bb++22]]
  2027.           and suppose that the next command invoked is one of the
  2028.           ones  on the left side of the table below.  The command
  2029.           actually recorded in the  history  event  will  be  the
  2030.           corresponding one on the right side of the table.
  2031.  
  2032.                Command Typed_____________    Command Recorded________________
  2033.  
  2034.                hhiissttoorryy         sseett aa [[eexxpprr $$bb++22]]
  2035.                hhiissttoorryy ss aa bb   sseett bb [[eexxpprr $$bb++22]]
  2036.                sseett cc [[hhiissttoorryy ww 22]]sseett cc [[eexxpprr $$bb++22]]
  2037.           History revision is  needed  because  event  specifiers  |
  2038.           like --11 are only valid at a particular time:  once more  |
  2039.           events have been added to the history list a  different  |
  2040.  
  2041.  
  2042.  
  2043. Sprite v1.0                                                    31
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. Tcl                   C Library Procedures                    Tcl
  2051.  
  2052.  
  2053.  
  2054.           event  specifier  would  be  needed.   History revision  |
  2055.           occurs even when hhiissttoorryy is invoked indirectly from the  |
  2056.           current event (e.g. a user types a command that invokes  |
  2057.           a Tcl procedure that invokes hhiissttoorryy):   the  top-level  |
  2058.           command  whose  execution eventually resulted in a hhiiss--  |
  2059.           ttoorryy command is replaced.  If you wish to  invoke  com-  |
  2060.           mands  like hhiissttoorryy wwoorrddss without history revision, you  |
  2061.           can use hhiissttoorryy eevveenntt to save the current history event  |
  2062.           and then use hhiissttoorryy cchhaannggee to restore it later.
  2063.  
  2064.      iiff _t_e_s_t ?tthheenn? _t_r_u_e_B_o_d_y ?eellssee? ?_f_a_l_s_e_B_o_d_y?
  2065.           The _i_f command evaluates _t_e_s_t as an expression (in  the
  2066.           same  way that eexxpprr evaluates its argument).  The value
  2067.           of the expression must be numeric; if  it  is  non-zero
  2068.           then _t_r_u_e_B_o_d_y is called by passing it to the Tcl inter-
  2069.           preter.  Otherwise _f_a_l_s_e_B_o_d_y is executed by passing  it
  2070.           to  the  Tcl  interpreter.  The tthheenn and eellssee arguments
  2071.           are optional ``noise words'' to make the command easier
  2072.           to  read.   _F_a_l_s_e_B_o_d_y  is  also  optional;  if it isn't
  2073.           specified then the command does nothing if _t_e_s_t  evalu-
  2074.           ates to zero.  The return value from iiff is the value of
  2075.           the last command executed in _t_r_u_e_B_o_d_y or _f_a_l_s_e_B_o_d_y,  or
  2076.           the  empty  string if _t_e_s_t evaluates to zero and _f_a_l_s_e_-
  2077.           _B_o_d_y isn't specified.
  2078.  
  2079.      iinnccrr _v_a_r_N_a_m_e ?_i_n_c_r_e_m_e_n_t?
  2080.           Increment the value stored in the variable  whose  name  |
  2081.           is   _v_a_r_N_a_m_e.   The  value  of  the  variable  must  be  |
  2082.           integral.  If _i_n_c_r_e_m_e_n_t  is  supplied  then  its  value  |
  2083.           (which  must  be  an  integer) is added to the value of  |
  2084.           variable _v_a_r_N_a_m_e;  otherwise 1  is  added  to  _v_a_r_N_a_m_e.  |
  2085.           The new value is stored as a decimal string in variable  |
  2086.           _v_a_r_N_a_m_e and also returned as result.
  2087.  
  2088.      iinnffoo _o_p_t_i_o_n ?_a_r_g _a_r_g ...?
  2089.           Provide information about various internals to the  Tcl
  2090.           interpreter.  The legal _o_p_t_i_o_n's (which may be abbrevi-
  2091.           ated) are:
  2092.  
  2093.           iinnffoo aarrggss _p_r_o_c_n_a_m_e
  2094.                Returns a list containing the names of  the  argu-
  2095.                ments  to  procedure _p_r_o_c_n_a_m_e, in order.  _P_r_o_c_n_a_m_e
  2096.                must be the name of a Tcl command procedure.
  2097.  
  2098.           iinnffoo bbooddyy _p_r_o_c_n_a_m_e
  2099.                Returns the body of procedure _p_r_o_c_n_a_m_e.   _P_r_o_c_n_a_m_e
  2100.                must be the name of a Tcl command procedure.
  2101.  
  2102.           iinnffoo ccmmddccoouunntt
  2103.                Returns a count of the total  number  of  commands
  2104.                that have been invoked in this interpreter.
  2105.  
  2106.  
  2107.  
  2108.  
  2109. Sprite v1.0                                                    32
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. Tcl                   C Library Procedures                    Tcl
  2117.  
  2118.  
  2119.  
  2120.           iinnffoo ccoommmmaannddss ?_p_a_t_t_e_r_n?
  2121.                If _p_a_t_t_e_r_n isn't  specified,  returns  a  list  of
  2122.                names  of all the Tcl commands, including both the
  2123.                built-in commands written in  C  and  the  command
  2124.                procedures  defined  using  the  pprroocc command.  If
  2125.                _p_a_t_t_e_r_n is specified, only  those  names  matching
  2126.                _p_a_t_t_e_r_n  are  returned.   Matching  is  determined
  2127.                using the same rules as for ssttrriinngg mmaattcchh.
  2128.  
  2129.           iinnffoo ddeeffaauulltt _p_r_o_c_n_a_m_e _a_r_g _v_a_r_n_a_m_e
  2130.                _P_r_o_c_n_a_m_e must be the name of a  Tcl  command  pro-
  2131.                cedure  and _a_r_g must be the name of an argument to
  2132.                that procedure.  If _a_r_g  doesn't  have  a  default
  2133.                value  then  the  command returns 00.  Otherwise it
  2134.                returns 11 and places the default value of _a_r_g into
  2135.                variable _v_a_r_n_a_m_e.
  2136.  
  2137.           iinnffoo eexxiissttss _v_a_r_N_a_m_e
  2138.                Returns 11 if the variable named _v_a_r_N_a_m_e exists  in
  2139.                the  current  context (either as a global or local
  2140.                variable), returns 00 otherwise.
  2141.  
  2142.           iinnffoo gglloobbaallss ?_p_a_t_t_e_r_n?
  2143.                If _p_a_t_t_e_r_n isn't specified, returns a list of  all
  2144.                the  names  of currently-defined global variables.
  2145.                If _p_a_t_t_e_r_n is specified, only those names matching
  2146.                _p_a_t_t_e_r_n  are  returned.   Matching  is  determined
  2147.                using the same rules as for ssttrriinngg mmaattcchh.
  2148.  
  2149.           iinnffoo lleevveell ?_n_u_m_b_e_r?
  2150.                If _n_u_m_b_e_r is not specified, this command returns a
  2151.                number giving the stack level of the invoking pro-
  2152.                cedure, or 0 if the command  is  invoked  at  top-
  2153.                level.  If _n_u_m_b_e_r is specified, then the result is
  2154.                a list consisting of the name  and  arguments  for
  2155.                the  procedure  call at level _n_u_m_b_e_r on the stack.
  2156.                If _n_u_m_b_e_r is positive then it selects a particular
  2157.                stack  level (1 refers to the top-most active pro-
  2158.                cedure, 2 to the procedure it called, and so  on);
  2159.                otherwise it gives a level relative to the current
  2160.                level (0 refers to the current  procedure,  -1  to
  2161.                its  caller,  and so on).  See the uupplleevveell command
  2162.                for more information on what stack levels mean.
  2163.  
  2164.           iinnffoo lliibbrraarryy
  2165.                Returns the name of the library directory in which  |
  2166.                standard  Tcl  scripts are stored.  If there is no  |
  2167.                such directory defined for the  current  installa-  |
  2168.                tion  then an error is generated.  See the lliibbrraarryy  |
  2169.                manual entry for details of  the  facilities  pro-  |
  2170.                vided  by  the  Tcl script library.  Normally each  |
  2171.                application will have its own application-specific  |
  2172.  
  2173.  
  2174.  
  2175. Sprite v1.0                                                    33
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. Tcl                   C Library Procedures                    Tcl
  2183.  
  2184.  
  2185.  
  2186.                script  library  in  addition  to  the  Tcl script  |
  2187.                library;  I suggest that each  application  set  a  |
  2188.                global  variable  with  a  name  like  $$_a_p_pLLiibbrraarryy  |
  2189.                (where _a_p_p is the application's name) to hold  the  |
  2190.                location of that application's library directory.
  2191.  
  2192.           iinnffoo llooccaallss ?_p_a_t_t_e_r_n?
  2193.                If _p_a_t_t_e_r_n isn't specified, returns a list of  all
  2194.                the  names  of  currently-defined local variables,
  2195.                including arguments to the current  procedure,  if
  2196.                any.   Variables defined with the gglloobbaall and uuppvvaarr  |
  2197.                commands will not  be  returned.   If  _p_a_t_t_e_r_n  is
  2198.                specified,  only  those names matching _p_a_t_t_e_r_n are
  2199.                returned.  Matching is determined using  the  same
  2200.                rules as for ssttrriinngg mmaattcchh.
  2201.  
  2202.           iinnffoo pprrooccss ?_p_a_t_t_e_r_n?
  2203.                If _p_a_t_t_e_r_n isn't specified, returns a list of  all
  2204.                the  names  of Tcl command procedures.  If _p_a_t_t_e_r_n
  2205.                is specified, only those  names  matching  _p_a_t_t_e_r_n
  2206.                are  returned.   Matching  is determined using the
  2207.                same rules as for ssttrriinngg mmaattcchh.
  2208.  
  2209.           iinnffoo ssccrriipptt
  2210.                If a Tcl script file is currently being  evaluated  |
  2211.                (i.e.  there  is  a call to TTccll__EEvvaallFFiillee active or  |
  2212.                there is an active invocation of the  ssoouurrccee  com-  |
  2213.                mand),  then  this command returns the name of the  |
  2214.                innermost file  being  processed.   Otherwise  the  |
  2215.                command returns an empty string.
  2216.  
  2217.           iinnffoo ttccllvveerrssiioonn
  2218.                Returns the version number for this version of Tcl
  2219.                in  the  form  _x._y,  where  changes to _x represent
  2220.                major changes with probable incompatibilities  and
  2221.                changes  to _y represent small enhancements and bug
  2222.                fixes that retain backward compatibility.
  2223.  
  2224.           iinnffoo vvaarrss ?_p_a_t_t_e_r_n?
  2225.                If _p_a_t_t_e_r_n isn't specified, returns a list of  all
  2226.                the  names of currently-visible variables, includ-
  2227.                ing both locals and currently-visible globals.  If
  2228.                _p_a_t_t_e_r_n  is  specified,  only those names matching
  2229.                _p_a_t_t_e_r_n  are  returned.   Matching  is  determined
  2230.                using the same rules as for ssttrriinngg mmaattcchh.
  2231.  
  2232.      jjooiinn _l_i_s_t ?_j_o_i_n_S_t_r_i_n_g?
  2233.           The _l_i_s_t argument must be a valid Tcl list.  This  com-  |
  2234.           mand  returns  the  string formed by joining all of the  |
  2235.           elements of _l_i_s_t together  with  _j_o_i_n_S_t_r_i_n_g  separating  |
  2236.           each  adjacent  pair of elements.  The _j_o_i_n_S_t_r_i_n_g argu-  |
  2237.           ment defaults to a space character.
  2238.  
  2239.  
  2240.  
  2241. Sprite v1.0                                                    34
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. Tcl                   C Library Procedures                    Tcl
  2249.  
  2250.  
  2251.  
  2252.      llaappppeenndd _v_a_r_N_a_m_e _v_a_l_u_e ?_v_a_l_u_e _v_a_l_u_e ...?
  2253.           Treat the variable given  by  _v_a_r_N_a_m_e  as  a  list  and  |
  2254.           append  each  of  the _v_a_l_u_e arguments to that list as a  |
  2255.           separate element, with  spaces  between  elements.   If  |
  2256.           _v_a_r_N_a_m_e  doesn't  exist,  it  is created as a list with  |
  2257.           elements given by  the  _v_a_l_u_e  arguments.   LLaappppeenndd  is  |
  2258.           similar  to  aappppeenndd except that the _v_a_l_u_es are appended  |
  2259.           as list elements rather than raw  text.   This  command  |
  2260.           provides  a  relatively efficient way to build up large  |
  2261.           lists.  For example, ``llaappppeenndd  aa  $$bb''  is  much  more  |
  2262.           efficient  than ``sseett aa [[ccoonnccaatt $$aa [[lliisstt $$bb]]]]'' when $$aa  |
  2263.           is long.                                                 |
  2264.  
  2265.      lliinnddeexx _l_i_s_t _i_n_d_e_x                                                  ||
  2266.           Treats _l_i_s_t as a Tcl list and returns the _i_n_d_e_x'th ele-  |
  2267.           ment from it (0 refers to  the  first  element  of  the  |
  2268.           list).   In extracting the element, _l_i_n_d_e_x observes the  |
  2269.           same rules concerning braces and quotes and backslashes  |
  2270.           as  the Tcl command interpreter; however, variable sub-  |
  2271.           stitution and command substitution do  not  occur.   If  |
  2272.           _i_n_d_e_x  is  negative  or  greater  than  or equal to the  |
  2273.           number of elements in _v_a_l_u_e, then an  empty  string  is  |
  2274.           returned.                                                |
  2275.  
  2276.      lliinnsseerrtt _l_i_s_t _i_n_d_e_x _e_l_e_m_e_n_t ?_e_l_e_m_e_n_t _e_l_e_m_e_n_t ...?                   ||
  2277.           This command produces a new list from _l_i_s_t by inserting  |
  2278.           all of the _e_l_e_m_e_n_t arguments just  before  the  _i_n_d_e_xth  |
  2279.           element  of  _l_i_s_t.  Each _e_l_e_m_e_n_t argument will become a  |
  2280.           separate element of the new list.   If  _i_n_d_e_x  is  less  |
  2281.           than  or  equal  to  zero,  then  the  new elements are  |
  2282.           inserted at the beginning of the  list.   If  _i_n_d_e_x  is  |
  2283.           greater  than or equal to the number of elements in the  |
  2284.           list, then the new elements are appended to the list.
  2285.  
  2286.      lliisstt _a_r_g ?_a_r_g ...?
  2287.           This command returns a list comprised of all the  _a_r_gs.
  2288.           Braces  and backslashes get added as necessary, so that
  2289.           the iinnddeexx command may be used  on  the  result  to  re-
  2290.           extract  the  original arguments, and also so that eevvaall
  2291.           may be used to execute the resulting  list,  with  _a_r_g_1
  2292.           comprising  the  command's  name  and  the  other  _a_r_gs
  2293.           comprising its arguments.  LLiisstt produces slightly  dif-
  2294.           ferent  results  than ccoonnccaatt:  ccoonnccaatt removes one level
  2295.           of grouping before forming the list, while  lliisstt  works
  2296.           directly from the original arguments.  For example, the
  2297.           command
  2298.  
  2299.                lliisstt aa bb {{cc dd ee}} {{ff {{gg hh}}}}
  2300.           will return
  2301.  
  2302.                aa bb {{cc dd ee}} {{ff {{gg hh}}}}
  2303.           while ccoonnccaatt with the same arguments will return
  2304.  
  2305.  
  2306.  
  2307. Sprite v1.0                                                    35
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. Tcl                   C Library Procedures                    Tcl
  2315.  
  2316.  
  2317.  
  2318.                aa bb cc dd ee ff {{gg hh}}
  2319.  
  2320.      lllleennggtthh _l_i_s_t                                                       ||
  2321.           Treats _l_i_s_t as a list and returns a decimal string giv-  |
  2322.           ing the number of elements in it.                        |
  2323.  
  2324.      llrraannggee _l_i_s_t _f_i_r_s_t _l_a_s_t                                             ||
  2325.           _L_i_s_t  must  be  a  valid  Tcl  list.  This command will  |
  2326.           return a new list consisting of elements _f_i_r_s_t  through  |
  2327.           _l_a_s_t,  inclusive.  _L_a_s_t may be eenndd (or any abbreviation  |
  2328.           of it) to refer to the last element of  the  list.   If  |
  2329.           _f_i_r_s_t  is  less  than zero, it is treated as if it were  |
  2330.           zero.  If _l_a_s_t is greater than or equal to  the  number  |
  2331.           of  elements  in  the list, then it is treated as if it  |
  2332.           were eenndd.  If _f_i_r_s_t is greater than _l_a_s_t then an  empty  |
  2333.           string  is returned.  Note: ``llrraannggee _l_i_s_t _f_i_r_s_t _f_i_r_s_t''  |
  2334.           does not always produce the  same  result  as  ``lliinnddeexx  |
  2335.           _l_i_s_t  _f_i_r_s_t'' (although it often does for simple fields  |
  2336.           that aren't enclosed in braces); it does, however, pro-  |
  2337.           duce  exactly  the  same results as ``lliisstt [[lliinnddeexx _l_i_s_t  |
  2338.           _f_i_r_s_t]]''                                                 |
  2339.  
  2340.      llrreeppllaaccee _l_i_s_t _f_i_r_s_t _l_a_s_t ?_e_l_e_m_e_n_t _e_l_e_m_e_n_t ...?                     ||
  2341.           Returns a new list formed by replacing one or more ele-  |
  2342.           ments of _l_i_s_t with the _e_l_e_m_e_n_t arguments.  _F_i_r_s_t  gives  |
  2343.           the  index in _l_i_s_t of the first element to be replaced.  |
  2344.           If _f_i_r_s_t is less than zero then it refers to the  first  |
  2345.           element  of  _l_i_s_t;  the element indicated by _f_i_r_s_t must  |
  2346.           exist in the list.  _L_a_s_t gives the index in _l_i_s_t of the  |
  2347.           last  element  to be replaced;  it must be greater than  |
  2348.           or equal to _f_i_r_s_t.  _L_a_s_t may be eenndd (or  any  abbrevia-  |
  2349.           tion of it) to indicate that all elements between _f_i_r_s_t  |
  2350.           and the end of the list should be replaced.   The  _e_l_e_-  |
  2351.           _m_e_n_t arguments specify zero or more new arguments to be  |
  2352.           added to the list in place of those that were  deleted.  |
  2353.           Each _e_l_e_m_e_n_t argument will become a separate element of  |
  2354.           the list.  If no _e_l_e_m_e_n_t arguments are specified,  then  |
  2355.           the elements between _f_i_r_s_t and _l_a_s_t are simply deleted.  |
  2356.  
  2357.      llsseeaarrcchh _l_i_s_t _p_a_t_t_e_r_n                                               ||
  2358.           Search  the  elements  of  _l_i_s_t  to  see if one of them  |
  2359.           matches _p_a_t_t_e_r_n.  If so, the command returns the  index  |
  2360.           of  the  first  matching  element.  If not, the command  |
  2361.           returns --11.  Pattern matching is done in the  same  way  |
  2362.           as for the ssttrriinngg mmaattcchh command.                         |
  2363.  
  2364.      llssoorrtt _l_i_s_t                                                         ||
  2365.           Sort  the  elements  of  _l_i_s_t,  returning a new list in  |
  2366.           sorted order.  ASCII sorting is used, with  the  result  |
  2367.           in increasing order.
  2368.  
  2369.      ooppeenn _f_i_l_e_N_a_m_e ?_a_c_c_e_s_s?
  2370.  
  2371.  
  2372.  
  2373. Sprite v1.0                                                    36
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. Tcl                   C Library Procedures                    Tcl
  2381.  
  2382.  
  2383.  
  2384.           Opens a file and returns an identifier that may be used  |
  2385.           in  future invocations of commands like rreeaadd, ppuuttss, and  |
  2386.           cclloossee.  _F_i_l_e_N_a_m_e gives the name of the file to open; if  |
  2387.           it  starts with a tilde then tilde substitution is per-  |
  2388.           formed as described for TTccll__TTiillddeeSSuubbsstt.  If  the  first  |
  2389.           character of _f_i_l_e_N_a_m_e is ``|'' then the remaining char-  |
  2390.           acters of _f_i_l_e_N_a_m_e are treated as a command pipeline to  |
  2391.           invoke,  in  the same style as for eexxeecc.  In this case,  |
  2392.           the identifier returned by ooppeenn may be used to write to  |
  2393.           the  command's input pipe or read from its output pipe.  |
  2394.           The _a_c_c_e_s_s argument indicates the way in which the file  |
  2395.           (or  command  pipeline) is to be accessed.  It may have  |
  2396.           any of the following values:                             |
  2397.  
  2398.           rr                                                             ||
  2399.                Open  the  file  for  reading  only; the file must  |
  2400.                already exist.                                      |
  2401.  
  2402.           rr++                                                            ||
  2403.                Open  the  file  for both reading and writing; the  |
  2404.                file must already exist.                            |
  2405.  
  2406.           ww                                                             ||
  2407.                Open the file for writing only.  Truncate it if it  |
  2408.                exists.  If it doesn't exist, create a new file.    |
  2409.  
  2410.           ww++                                                            ||
  2411.                Open  the  file for reading and writing.  Truncate  |
  2412.                it if it exists.  If it doesn't  exist,  create  a  |
  2413.                new file.                                           |
  2414.  
  2415.           aa                                                             ||
  2416.                Open  the  file  for  writing only.  The file must  |
  2417.                already exist, and the file is positioned so  that  |
  2418.                new data is appended to the file.                   |
  2419.  
  2420.           aa++                                                            ||
  2421.                Open  the  file for reading and writing.  The file  |
  2422.                must already exist, and the initial  access  posi-  |
  2423.                tion is set to the end of the file.                 |
  2424.  
  2425.           _A_c_c_e_s_s defaults to rr.  If a file  is  opened  for  both  |
  2426.           reading  and writing, then sseeeekk must be invoked between  |
  2427.           a read and a write, or  vice  versa  (this  restriction  |
  2428.           does  not apply to command pipelines opened with ooppeenn).  |
  2429.           When  _f_i_l_e_N_a_m_e  specifies  a  command  pipeline  and  a  |
  2430.           write-only  access  is  used, then standard output from  |
  2431.           the pipeline is directed to the current standard output  |
  2432.           unless overridden by the command.  When _f_i_l_e_N_a_m_e speci-  |
  2433.           fies a command pipeline and a read-only access is used,  |
  2434.           then standard input from the pipeline is taken from the  |
  2435.           current  standard  input  unless  overridden   by   the  |
  2436.  
  2437.  
  2438.  
  2439. Sprite v1.0                                                    37
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. Tcl                   C Library Procedures                    Tcl
  2447.  
  2448.  
  2449.  
  2450.           command.                                                 |
  2451.  
  2452.      pprroocc _n_a_m_e _a_r_g_s _b_o_d_y
  2453.           The pprroocc command creates a new Tcl  command  procedure,
  2454.           _n_a_m_e,  replacing  any  existing  command there may have
  2455.           been  by  that  name.   Whenever  the  new  command  is
  2456.           invoked,  the  contents of _b_o_d_y will be executed by the
  2457.           Tcl interpreter.  _A_r_g_s specifies the  formal  arguments
  2458.           to  the  procedure.   It  consists  of a list, possibly
  2459.           empty, each of whose elements specifies  one  argument.
  2460.           Each  argument specifier is also a list with either one
  2461.           or two fields.  If there is only a single field in  the
  2462.           specifier,  then  it  is  the  name of the argument; if
  2463.           there are two fields, then the first  is  the  argument
  2464.           name  and  the second is its default value.  braces and
  2465.           backslashes may be used in the  usual  way  to  specify
  2466.           complex default values.
  2467.  
  2468.           When _n_a_m_e is invoked, a local variable will be  created
  2469.           for  each of the formal arguments to the procedure; its
  2470.           value will be the value of  corresponding  argument  in
  2471.           the  invoking  command or the argument's default value.
  2472.           Arguments with default values need not be specified  in
  2473.           a  procedure invocation.  However, there must be enough
  2474.           actual arguments for  all  the  formal  arguments  that
  2475.           don't  have  defaults,  and there must not be any extra
  2476.           actual arguments.  There is one special case to  permit
  2477.           procedures  with variable numbers of arguments.  If the
  2478.           last formal argument has the name aarrggss, then a call  to
  2479.           the  procedure  may  contain more actual arguments than
  2480.           the procedure has formals.  In this case,  all  of  the
  2481.           actual  arguments  starting  at  the  one that would be
  2482.           assigned to aarrggss are combined into a list  (as  if  the
  2483.           lliisstt  command  had  been  used); this combined value is
  2484.           assigned to the local variable aarrggss.
  2485.  
  2486.           When _b_o_d_y is being executed,  variable  names  normally
  2487.           refer  to  local variables, which are created automati-
  2488.           cally when referenced and deleted  when  the  procedure
  2489.           returns.   One  local variable is automatically created
  2490.           for each of the procedure's  arguments.   Global  vari-
  2491.           ables  can only be accessed by invoking the gglloobbaall com-
  2492.           mand.
  2493.  
  2494.           The pprroocc command returns the null string.  When a  pro-
  2495.           cedure  is invoked, the procedure's return value is the
  2496.           value specified in a rreettuurrnn command.  If the  procedure
  2497.           doesn't  execute  an  explicit  rreettuurrnn, then its return
  2498.           value is the value of the last command executed in  the
  2499.           procedure's  body.   If an error occurs while executing
  2500.           the procedure body, then the procedure-as-a-whole  will
  2501.           return that same error.
  2502.  
  2503.  
  2504.  
  2505. Sprite v1.0                                                    38
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. Tcl                   C Library Procedures                    Tcl
  2513.  
  2514.  
  2515.  
  2516.      ppuuttss _f_i_l_e_I_d _s_t_r_i_n_g ?nnoonneewwlliinnee?
  2517.           Writes the characters given by _s_t_r_i_n_g to the file given  |
  2518.           by  _f_i_l_e_I_d.   PPuuttss normally outputs a newline character  |
  2519.           after _s_t_r_i_n_g, but this feature  may  be  suppressed  by  |
  2520.           specifying  the nnoonneewwlliinnee argument.  Output to files is  |
  2521.           buffered internally by Tcl; the fflluusshh  command  may  be  |
  2522.           used to force buffered characters to be output.  _F_i_l_e_I_d  |
  2523.           must have been the return value from a previous call to  |
  2524.           ooppeenn,  or it may be ssttddoouutt or ssttddeerrrr to refer to one of  |
  2525.           the standard I/O channels; it must refer to a file that  |
  2526.           was opened for writing.                                  |
  2527.  
  2528.      ppwwdd                                                                ||
  2529.           Returns the path name of the current working directory.  |
  2530.  
  2531.      rreeaadd _f_i_l_e_I_d                                                        ||
  2532.  
  2533.      rreeaadd _f_i_l_e_I_d nnoonneewwlliinnee                                              ||
  2534.  
  2535.      rreeaadd _f_i_l_e_I_d _n_u_m_B_y_t_e_s                                               ||
  2536.           In  the first form, all of the remaining bytes are read  |
  2537.           from the file given by _f_i_l_e_I_d; they are returned as the  |
  2538.           result of the command.  If nnoonneewwlliinnee is specified as an  |
  2539.           additional argument, then the  last  character  of  the  |
  2540.           file  is  discarded  if  it is a newline.  In the third  |
  2541.           form, the extra argument specifies how  many  bytes  to  |
  2542.           read;   exactly  this  many  bytes  will  be  read  and  |
  2543.           returned, unless there are fewer  than  _n_u_m_B_y_t_e_s  bytes  |
  2544.           left in the file; in this case, all the remaining bytes  |
  2545.           are returned.  _F_i_l_e_I_d must be ssttddiinn or the return value  |
  2546.           from  a  previous call to ooppeenn; it must refer to a file  |
  2547.           that was opened for reading.                             |
  2548.  
  2549. _s_u_b_M_a_t_c_h_-  |
  2550. _V_a_r ...?                                                   |       |
  2551.      rreeggeexxpp ?--iinnddiicceess? ?--nnooccaassee? _e_x_p  _s_t_r_i_n_g  ?_m_a_t_c_h_V_a_r?  ?_s_u_b_M_a_t_c_h_V_a_r  ||
  2552.           Determines  whether  the regular expression _e_x_p matches  |
  2553.           part or all of _s_t_r_i_n_g and returns 1 if it does, 0 if it  |
  2554.           doesn't.   See  REGULAR  EXPRESSIONS above for complete  |
  2555.           information on the syntax of _e_x_p and how it is  matched  |
  2556.           against _s_t_r_i_n_g.                                          |
  2557.  
  2558.           If the --nnooccaassee  switch  is  specified  then  upper-case  |
  2559.           characters  in  _s_t_r_i_n_g are treated as lower case during  |
  2560.           the matching  process.   The  --nnooccaassee  switch  must  be  |
  2561.           specified before _e_x_p and may not be abbreviated.         |
  2562.  
  2563.           If additional arguments are specified after _s_t_r_i_n_g then  |
  2564.           they  are  treated  as the names of variables to use to  |
  2565.           return  information  about  which  part(s)  of   _s_t_r_i_n_g  |
  2566.           matched  _e_x_p.   _M_a_t_c_h_V_a_r  will  be  set to the range of  |
  2567.           _s_t_r_i_n_g that matched all of _e_x_p.  The first  _s_u_b_M_a_t_c_h_V_a_r  |
  2568.  
  2569.  
  2570.  
  2571. Sprite v1.0                                                    39
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. Tcl                   C Library Procedures                    Tcl
  2579.  
  2580.  
  2581.  
  2582.           will  contain the characters in _s_t_r_i_n_g that matched the  |
  2583.           leftmost parenthesized subexpression  within  _e_x_p,  the  |
  2584.           next  _s_u_b_M_a_t_c_h_V_a_r  will  contain  the  characters  that  |
  2585.           matched the next  parenthesized  subexpression  to  the  |
  2586.           right in _e_x_p, and so on.                                 |
  2587.  
  2588.           Normally, _m_a_t_c_h_V_a_r and the _s_u_b_M_a_t_c_h_V_a_rs are set to hold  |
  2589.           the  matching  characters from ssttrriinngg.  However, if the  |
  2590.           --iinnddiicceess switch is specified then  each  variable  will  |
  2591.           contain  a  list  of  two  decimal  strings  giving the  |
  2592.           indices in _s_t_r_i_n_g of the first and last  characters  in  |
  2593.           the  matching range of characters.  The --iinnddiicceess switch  |
  2594.           must be specified before the _e_x_p argument and  may  not  |
  2595.           be abbreviated.                                          |
  2596.  
  2597.           If there  are  more  _s_u_b_M_a_t_c_h_V_a_r's  than  parenthesized  |
  2598.           subexpressions  within  _e_x_p,  or if a particular subex-  |
  2599.           pression in _e_x_p doesn't match the string (e.g.  because  |
  2600.           it  was  in  a  portion  of  the expression that wasn't  |
  2601.           matched), then the corresponding  _s_u_b_M_a_t_c_h_V_a_r  will  be  |
  2602.           set  to  ``--11 --11'' if --iinnddiicceess has been specified or to  |
  2603.           an empty string otherwise.                               |
  2604.  
  2605.      rreeggssuubb ?--aallll? ?--nnooccaassee? _e_x_p _s_t_r_i_n_g _s_u_b_S_p_e_c _v_a_r_N_a_m_e                 ||
  2606.           This command matches the regular expression _e_x_p against  |
  2607.           _s_t_r_i_n_g using the rules described in REGULAR EXPRESSIONS  |
  2608.           above.   If there is no match, then the command returns  |
  2609.           0 and does nothing else.  If there is a match, then the  |
  2610.           command  returns  1 and also copies _s_t_r_i_n_g to the vari-  |
  2611.           able whose name is  given  by  _v_a_r_N_a_m_e.   When  copying  |
  2612.           _s_t_r_i_n_g,  the  portion  of  _s_t_r_i_n_g  that  matched _e_x_p is  |
  2613.           replaced with _s_u_b_S_p_e_c.  If _s_u_b_S_p_e_c contains a ``&''  or  |
  2614.           ``\0'',  then  it  is replaced in the substitution with  |
  2615.           the portion of _s_t_r_i_n_g that  matched  _e_x_p.   If  _s_u_b_S_p_e_c  |
  2616.           contains  a ``\_n'', where _n is a digit between 1 and 9,  |
  2617.           then it is replaced in the substitution with  the  por-  |
  2618.           tion  of  _s_t_r_i_n_g  that  matched  the _n-th parenthesized  |
  2619.           subexpression of _e_x_p.  Additional  backslashes  may  be  |
  2620.           used  in  _s_u_b_S_p_e_c  to prevent special interpretation of  |
  2621.           ``&'' or ``\0'' or ``\_n'' or  backslash.   The  use  of  |
  2622.           backslashes in _s_u_b_S_p_e_c tends to interact badly with the  |
  2623.           Tcl parser's use  of  backslashes,  so  it's  generally  |
  2624.           safest  to  enclose  _s_u_b_S_p_e_c  in  braces if it includes  |
  2625.           backslashes.  If the --aallll argument is  specified,  then  |
  2626.           all  ranges in _s_t_r_i_n_g that match _e_x_p are found and sub-  |
  2627.           stitution is performed for each of these ranges;   oth-  |
  2628.           erwise  only the first matching range is found and sub-  |
  2629.           stituted.  If --aallll is specified, then ``&'' and  ``\_n''  |
  2630.           sequences  are  handled for each substitution using the  |
  2631.           information  from  the  corresponding  match.   If  the  |
  2632.           --nnooccaassee  argument is specified, then upper-case charac-  |
  2633.           ters in  _s_t_r_i_n_g  are  converted  to  lower-case  before  |
  2634.  
  2635.  
  2636.  
  2637. Sprite v1.0                                                    40
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. Tcl                   C Library Procedures                    Tcl
  2645.  
  2646.  
  2647.  
  2648.           matching against _e_x_p;  however, substitutions specified  |
  2649.           by _s_u_b_S_p_e_c use the original unconverted form of _s_t_r_i_n_g.  |
  2650.           The  --aallll  and  --nnooccaassee  arguments  must  be  specified  |
  2651.           exactly:  no abbreviations are permitted.
  2652.  
  2653.      rreennaammee _o_l_d_N_a_m_e _n_e_w_N_a_m_e
  2654.           Rename the command that used to be  called  _o_l_d_N_a_m_e  so
  2655.           that  it is now called _n_e_w_N_a_m_e.  If _n_e_w_N_a_m_e is an empty
  2656.           string (e.g. {}) then _o_l_d_N_a_m_e is deleted.   The  rreennaammee
  2657.           command returns an empty string as result.
  2658.  
  2659.      rreettuurrnn ?_v_a_l_u_e?
  2660.           Return immediately from the current procedure (or  top-
  2661.           level  command  or  ssoouurrccee  command), with _v_a_l_u_e as the
  2662.           return value.  If _v_a_l_u_e  is  not  specified,  an  empty
  2663.           string will be returned as result.
  2664.  
  2665.      ssccaann _s_t_r_i_n_g _f_o_r_m_a_t _v_a_r_n_a_m_e_1 ?_v_a_r_n_a_m_e_2 ...?
  2666.           This command parses fields from an input string in  the
  2667.           same  fashion  as the C ssssccaannff procedure.  _S_t_r_i_n_g gives
  2668.           the input to be parsed  and  _f_o_r_m_a_t  indicates  how  to
  2669.           parse  it,  using  %%  fields  as in ssssccaannff.  All of the
  2670.           ssssccaannff options are valid; see the ssssccaannff man  page  for
  2671.           details.   Each  _v_a_r_n_a_m_e  gives the name of a variable;
  2672.           when a field is scanned from _s_t_r_i_n_g, the result is con-
  2673.           verted   back   into  a  string  and  assigned  to  the
  2674.           corresponding _v_a_r_n_a_m_e.  The only unusual conversion  is
  2675.           for %%cc.  For %%cc conversions a single character value is
  2676.           converted to a decimal string, which is  then  assigned
  2677.           to  the  corresponding  _v_a_r_n_a_m_e;  no field width may be  |
  2678.           specified for this conversion.                           |
  2679.  
  2680.      sseeeekk _f_i_l_e_I_d _o_f_f_s_e_t ?_o_r_i_g_i_n?                                        ||
  2681.           Change  the  current  access  position for _f_i_l_e_I_d.  The  |
  2682.           _o_f_f_s_e_t and _o_r_i_g_i_n arguments  specify  the  position  at  |
  2683.           which  the  next  read  or write will occur for _f_i_l_e_I_d.  |
  2684.           _O_f_f_s_e_t must be a number (which  may  be  negative)  and  |
  2685.           _o_r_i_g_i_n must be one of the following:                     |
  2686.  
  2687.           ssttaarrtt                                                         ||
  2688.                The  new access position will be _o_f_f_s_e_t bytes from  |
  2689.                the start of the file.                              |
  2690.  
  2691.           ccuurrrreenntt                                                       ||
  2692.                The  new access position will be _o_f_f_s_e_t bytes from  |
  2693.                the current access  position;  a  negative  _o_f_f_s_e_t  |
  2694.                moves the access position backwards in the file.    |
  2695.  
  2696.           eenndd                                                           ||
  2697.                The  new access position will be _o_f_f_s_e_t bytes from  |
  2698.                the end of the file.  A negative _o_f_f_s_e_t places the  |
  2699.                access  position  before  the  end-of-file,  and a  |
  2700.  
  2701.  
  2702.  
  2703. Sprite v1.0                                                    41
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. Tcl                   C Library Procedures                    Tcl
  2711.  
  2712.  
  2713.  
  2714.                positive _o_f_f_s_e_t places the access  position  after  |
  2715.                the end-of-file.                                    |
  2716.  
  2717.           The _o_r_i_g_i_n argument defaults  to  ssttaarrtt.   _F_i_l_e_I_d  must  |
  2718.           have  been  the  return  value  from a previous call to  |
  2719.           ooppeenn, or it may be ssttddiinn, ssttddoouutt, or ssttddeerrrr to refer to  |
  2720.           one of the standard I/O channels.  This command returns  |
  2721.           an empty string.                                         |
  2722.  
  2723.      sseett _v_a_r_n_a_m_e ?_v_a_l_u_e?
  2724.           Returns the value of variable  _v_a_r_n_a_m_e.   If  _v_a_l_u_e  is
  2725.           specified,  then  set  the  value  of _v_a_r_n_a_m_e to _v_a_l_u_e,
  2726.           creating a new variable if one doesn't  already  exist,
  2727.           and  return  its  value.   If  _v_a_r_N_a_m_e contains an open  |
  2728.           parenthesis and ends with a close parenthesis, then  it  |
  2729.           refers  to an array element:  the characters before the  |
  2730.           open parenthesis are the name of  the  array,  and  the  |
  2731.           characters between the parentheses are the index within  |
  2732.           the array.  Otherwise _v_a_r_N_a_m_e refers to a scalar  vari-  |
  2733.           able.   If  no procedure is active, then _v_a_r_n_a_m_e refers
  2734.           to a global variable.  If a procedure is  active,  then
  2735.           _v_a_r_n_a_m_e  refers to a parameter or local variable of the
  2736.           procedure, unless the _g_l_o_b_a_l command has  been  invoked
  2737.           to declare _v_a_r_n_a_m_e to be global.
  2738.  
  2739.      ssoouurrccee _f_i_l_e_N_a_m_e
  2740.           Read file _f_i_l_e_N_a_m_e and pass the  contents  to  the  Tcl
  2741.           interpreter as a sequence of commands to execute in the
  2742.           normal fashion.  The return  value  of  ssoouurrccee  is  the
  2743.           return  value  of  the  last  command executed from the
  2744.           file.  If an error occurs in executing the contents  of
  2745.           the  file,  then  the  ssoouurrccee  command will return that
  2746.           error.  If a rreettuurrnn command is invoked from within  the
  2747.           file, the remainder of the file will be skipped and the
  2748.           ssoouurrccee command will return  normally  with  the  result
  2749.           from  the  rreettuurrnn  command.   If _f_i_l_e_N_a_m_e starts with a
  2750.           tilde, then it is tilde-substituted as described in the
  2751.           TTccll__TTiillddeeSSuubbsstt manual entry.
  2752.  
  2753.      sspplliitt _s_t_r_i_n_g ?_s_p_l_i_t_C_h_a_r_s?
  2754.           Returns a list created  by  splitting  _s_t_r_i_n_g  at  each
  2755.           character  that  is  in  the _s_p_l_i_t_C_h_a_r_s argument.  Each
  2756.           element of the result list will consist of the  charac-
  2757.           ters from _s_t_r_i_n_g between instances of the characters in
  2758.           _s_p_l_i_t_C_h_a_r_s.  Empty list elements will be  generated  if
  2759.           _s_t_r_i_n_g  contains  adjacent characters in _s_p_l_i_t_C_h_a_r_s, or
  2760.           if  the  first  or  last  character  of  _s_t_r_i_n_g  is  in
  2761.           _s_p_l_i_t_C_h_a_r_s.  If _s_p_l_i_t_C_h_a_r_s is an empty string then each
  2762.           character of _s_t_r_i_n_g becomes a separate element  of  the
  2763.           result  list.   _S_p_l_i_t_C_h_a_r_s  defaults  to  the  standard
  2764.           white-space characters.  For example,
  2765.  
  2766.  
  2767.  
  2768.  
  2769. Sprite v1.0                                                    42
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. Tcl                   C Library Procedures                    Tcl
  2777.  
  2778.  
  2779.  
  2780.                sspplliitt ""ccoommpp..uunniixx..mmiisscc"" ..
  2781.           returns ""ccoommpp uunniixx mmiisscc"" and
  2782.  
  2783.                sspplliitt ""HHeelllloo wwoorrlldd"" {{}}
  2784.           returns ""HH ee ll ll oo {{ }} ww oo rr ll dd"".
  2785.  
  2786.      ssttrriinngg _o_p_t_i_o_n _a_r_g ?_a_r_g ...?
  2787.           Perform one of several string operations, depending  on
  2788.           _o_p_t_i_o_n.   The  legal _o_p_t_i_o_ns (which may be abbreviated)
  2789.           are:
  2790.  
  2791.           ssttrriinngg ccoommppaarree _s_t_r_i_n_g_1 _s_t_r_i_n_g_2
  2792.                Perform  a  character-by-character  comparison  of
  2793.                strings _s_t_r_i_n_g_1 and _s_t_r_i_n_g_2 in the same way as the
  2794.                C ssttrrccmmpp procedure.  Return -1, 0, or 1, depending
  2795.                on whether _s_t_r_i_n_g_1 is lexicographically less than,
  2796.                equal to, or greater than _s_t_r_i_n_g_2.
  2797.  
  2798.           ssttrriinngg ffiirrsstt _s_t_r_i_n_g_1 _s_t_r_i_n_g_2
  2799.                Search _s_t_r_i_n_g_2 for a sequence of  characters  that
  2800.                exactly  match  the  characters  in  _s_t_r_i_n_g_1.   If
  2801.                found, return the index of the first character  in
  2802.                the  first  such  match  within  _s_t_r_i_n_g_2.   If not
  2803.                found, return -1.
  2804.  
  2805.           ssttrriinngg iinnddeexx _s_t_r_i_n_g _c_h_a_r_I_n_d_e_x                                 ||
  2806.                Returns  the  _c_h_a_r_I_n_d_e_x'th character of the _s_t_r_i_n_g  |
  2807.                argument.  A _c_h_a_r_I_n_d_e_x of  0  corresponds  to  the  |
  2808.                first  character  of  the string.  If _c_h_a_r_I_n_d_e_x is  |
  2809.                less than 0 or greater than or equal to the length  |
  2810.                of the string then an empty string is returned.
  2811.  
  2812.           ssttrriinngg llaasstt _s_t_r_i_n_g_1 _s_t_r_i_n_g_2
  2813.                Search _s_t_r_i_n_g_2 for a sequence of  characters  that
  2814.                exactly  match  the  characters  in  _s_t_r_i_n_g_1.   If
  2815.                found, return the index of the first character  in
  2816.                the  last  such match within _s_t_r_i_n_g_2.  If there is
  2817.                no match, then return -1.
  2818.  
  2819.           ssttrriinngg lleennggtthh _s_t_r_i_n_g                                          ||
  2820.                Returns  a  decimal  string  giving  the number of  |
  2821.                characters in _s_t_r_i_n_g.
  2822.  
  2823.           ssttrriinngg mmaattcchh _p_a_t_t_e_r_n _s_t_r_i_n_g
  2824.                See if _p_a_t_t_e_r_n matches  _s_t_r_i_n_g;  return  1  if  it
  2825.                does,  0  if  it  doesn't.   Matching is done in a
  2826.                fashion similar to that used by the C-shell.   For
  2827.                the  two  strings to match, their contents must be
  2828.                identical  except  that  the   following   special
  2829.                sequences may appear in _p_a_t_t_e_r_n:
  2830.  
  2831.                **         Matches any sequence  of  characters  in
  2832.  
  2833.  
  2834.  
  2835. Sprite v1.0                                                    43
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. Tcl                   C Library Procedures                    Tcl
  2843.  
  2844.  
  2845.  
  2846.                          _s_t_r_i_n_g, including a null string.
  2847.  
  2848.                ??         Matches any single character in _s_t_r_i_n_g.
  2849.  
  2850.                [[_c_h_a_r_s]]   Matches any character in the  set  given
  2851.                          by _c_h_a_r_s.  If a sequence of the form _x--_y
  2852.                          appears in  _c_h_a_r_s,  then  any  character
  2853.                          between _x and _y, inclusive, will match.
  2854.  
  2855.                \\_x        Matches the single  character  _x.   This
  2856.                          provides  a  way of avoiding the special
  2857.                          interpretation of the  characters  **??[[]]\\
  2858.                          in _p_a_t_t_e_r_n.
  2859.  
  2860.           ssttrriinngg rraannggee _s_t_r_i_n_g _f_i_r_s_t _l_a_s_t                                ||
  2861.                Returns  a  range  of  consecutive characters from  |
  2862.                _s_t_r_i_n_g, starting with the character whose index is  |
  2863.                _f_i_r_s_t and ending with the character whose index is  |
  2864.                _l_a_s_t.  An index of 0 refers to the first character  |
  2865.                of  the string.  _L_a_s_t may be eenndd (or any abbrevia-  |
  2866.                tion of it) to refer to the last character of  the  |
  2867.                string.   If  _f_i_r_s_t  is  less than zero then it is  |
  2868.                treated as if it were zero, and if _l_a_s_t is greater  |
  2869.                than  or equal to the length of the string then it  |
  2870.                is treated as if it were eenndd.  If _f_i_r_s_t is greater  |
  2871.                than _l_a_s_t then an empty string is returned.         |
  2872.  
  2873.           ssttrriinngg ttoolloowweerr _s_t_r_i_n_g                                         ||
  2874.                Returns  a  value  equal to _s_t_r_i_n_g except that all  |
  2875.                upper case letters have been  converted  to  lower  |
  2876.                case.                                               |
  2877.  
  2878.           ssttrriinngg ttoouuppppeerr _s_t_r_i_n_g                                         ||
  2879.                Returns  a  value  equal to _s_t_r_i_n_g except that all  |
  2880.                lower case letters have been  converted  to  upper  |
  2881.                case.                                               |
  2882.  
  2883.           ssttrriinngg ttrriimm _s_t_r_i_n_g ?_c_h_a_r_s?                                    ||
  2884.                Returns  a  value  equal to _s_t_r_i_n_g except that any  |
  2885.                leading or trailing characters from the set  given  |
  2886.                by  _c_h_a_r_s  are removed.  If _c_h_a_r_s is not specified  |
  2887.                then white space is removed  (spaces,  tabs,  new-  |
  2888.                lines, and carriage returns).                       |
  2889.  
  2890.           ssttrriinngg ttrriimmlleefftt _s_t_r_i_n_g ?_c_h_a_r_s?                                ||
  2891.                Returns  a  value  equal to _s_t_r_i_n_g except that any  |
  2892.                leading characters from the set given by _c_h_a_r_s are  |
  2893.                removed.   If  _c_h_a_r_s  is  not specified then white  |
  2894.                space is removed (spaces, tabs, newlines, and car-  |
  2895.                riage returns).                                     |
  2896.  
  2897.           ssttrriinngg ttrriimmrriigghhtt _s_t_r_i_n_g ?_c_h_a_r_s?                               ||
  2898.  
  2899.  
  2900.  
  2901. Sprite v1.0                                                    44
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. Tcl                   C Library Procedures                    Tcl
  2909.  
  2910.  
  2911.  
  2912.                Returns  a  value  equal to _s_t_r_i_n_g except that any  |
  2913.                trailing characters from the set  given  by  _c_h_a_r_s  |
  2914.                are removed.  If _c_h_a_r_s is not specified then white  |
  2915.                space is removed (spaces, tabs, newlines, and car-  |
  2916.                riage returns).                                     |
  2917.  
  2918.      tteellll _f_i_l_e_I_d                                                        ||
  2919.           Returns  a  decimal  string  giving  the current access  |
  2920.           position in _f_i_l_e_I_d.  _F_i_l_e_I_d must have been  the  return  |
  2921.           value from a previous call to ooppeenn, or it may be ssttddiinn,  |
  2922.           ssttddoouutt, or ssttddeerrrr to refer to one of the  standard  I/O  |
  2923.           channels.
  2924.  
  2925.      ttiimmee _c_o_m_m_a_n_d ?_c_o_u_n_t?
  2926.           This command will call the Tcl interpreter _c_o_u_n_t  times
  2927.           to  execute _c_o_m_m_a_n_d (or once if _c_o_u_n_t isn't specified).
  2928.           It will then return a string of the form
  2929.  
  2930.                550033 mmiiccrroosseeccoonnddss ppeerr iitteerraattiioonn
  2931.           which indicates the average amount of time required per
  2932.           iteration,   in  microseconds.   Time  is  measured  in
  2933.           elapsed time, not CPU time.
  2934.  
  2935.      ttrraaccee _o_p_t_i_o_n ?_a_r_g _a_r_g ...?
  2936.           Cause Tcl commands  to  be  executed  whenever  certain  |
  2937.           operations  are  invoked.   At  present,  only variable  |
  2938.           tracing is implemented. The legal _o_p_t_i_o_n's  (which  may  |
  2939.           be abbreviated) are:                                     |
  2940.  
  2941.           ttrraaccee vvaarriiaabbllee _n_a_m_e _o_p_s _c_o_m_m_a_n_d                               ||
  2942.                Arrange  for _c_o_m_m_a_n_d to be executed whenever vari-  |
  2943.                able _n_a_m_e is accessed in one of the ways given  by  |
  2944.                _o_p_s.  _N_a_m_e may refer to a normal variable, an ele-  |
  2945.                ment of an array, or to an array as a whole  (i.e.  |
  2946.                _n_a_m_e  may  be  just  the name of an array, with no  |
  2947.                parenthesized index).  If _n_a_m_e refers to  a  whole  |
  2948.                array,  then  _c_o_m_m_a_n_d is invoked whenever any ele-  |
  2949.                ment of the array is manipulated.                   |
  2950.  
  2951.                _O_p_s indicates which operations  are  of  interest,  |
  2952.                and  consists  of  one  or  more  of the following  |
  2953.                letters:                                            |
  2954.  
  2955.                     rr                                                   ||
  2956.                          Invoke  _c_o_m_m_a_n_d whenever the variable is  |
  2957.                          read.                                     |
  2958.  
  2959.                     ww                                                   ||
  2960.                          Invoke  _c_o_m_m_a_n_d whenever the variable is  |
  2961.                          written.                                  |
  2962.  
  2963.                     uu                                                   ||
  2964.  
  2965.  
  2966.  
  2967. Sprite v1.0                                                    45
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974. Tcl                   C Library Procedures                    Tcl
  2975.  
  2976.  
  2977.  
  2978.                          Invoke  _c_o_m_m_a_n_d whenever the variable is  |
  2979.                          unset.  Variables can  be  unset  expli-  |
  2980.                          citly  with the uunnsseett command, or impli-  |
  2981.                          citly when  procedures  return  (all  of  |
  2982.                          their local variables are unset).  Vari-  |
  2983.                          ables are also unset  when  interpreters  |
  2984.                          are  deleted,  but  traces  will  not be  |
  2985.                          invoked because there is no  interpreter  |
  2986.                          in which to execute them.                 |
  2987.  
  2988.                When  the  trace  triggers,  three  arguments  are  |
  2989.                appended  to _c_o_m_m_a_n_d so that the actual command is  |
  2990.                as follows:                                         |
  2991.  
  2992.                     _c_o_m_m_a_n_d _n_a_m_e_1 _n_a_m_e_2 _o_p                         |
  2993.                _N_a_m_e_1 and _n_a_m_e_2 give the name(s) for the  variable  |
  2994.                being  accessed:  if the variable is a scalar then  |
  2995.                _n_a_m_e_1 gives the variable's name and  _n_a_m_e_2  is  an  |
  2996.                empty  string; if the variable is an array element  |
  2997.                then _n_a_m_e_1 gives the name of the array  and  name2  |
  2998.                gives the index into the array; if an entire array  |
  2999.                is being deleted and the trace was  registered  on  |
  3000.                the  overall  array, rather than a single element,  |
  3001.                then _n_a_m_e_1 gives the array name and  _n_a_m_e_2  is  an  |
  3002.                empty  string.   _O_p  indicates  what  operation is  |
  3003.                being performed on the variable, and is one of  rr,  |
  3004.                ww, or uu as defined above.                           |
  3005.  
  3006.                _C_o_m_m_a_n_d executes in the same context as  the  code  |
  3007.                that  invoked  the traced operation:  if the vari-  |
  3008.                able was accessed as part of a Tcl procedure, then  |
  3009.                _c_o_m_m_a_n_d  will  have access to the same local vari-  |
  3010.                ables as code in the procedure.  This context  may  |
  3011.                be  different  than the context in which the trace  |
  3012.                was  created.   If  _c_o_m_m_a_n_d  invokes  a  procedure  |
  3013.                (which  it  normally does) then the procedure will  |
  3014.                have to use uuppvvaarr  or  uupplleevveell  if  it  wishes  to  |
  3015.                access  the traced variable.  Note also that _n_a_m_e_1  |
  3016.                may not necessarily be the same as the  name  used  |
  3017.                to set the trace on the variable;  differences can  |
  3018.                occur if the access is  made  through  a  variable  |
  3019.                defined with the uuppvvaarr command.                     |
  3020.  
  3021.                For read and write traces, _c_o_m_m_a_n_d can modify  the  |
  3022.                variable to affect the result of the traced opera-  |
  3023.                tion.  If _c_o_m_m_a_n_d modifies the value of a variable  |
  3024.                during  a  read or write trace, then the new value  |
  3025.                will be returned  as  the  result  of  the  traced  |
  3026.                operation.   The  return  value  from   _c_o_m_m_a_n_d is  |
  3027.                ignored except that if it returns an error of  any  |
  3028.                sort  then the traced operation is aborted with an  |
  3029.                error message saying that the  access  was  denied  |
  3030.  
  3031.  
  3032.  
  3033. Sprite v1.0                                                    46
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. Tcl                   C Library Procedures                    Tcl
  3041.  
  3042.  
  3043.  
  3044.                (this mechanism can be used to implement read-only  |
  3045.                variables, for example).  For write  traces,  _c_o_m_-  |
  3046.                _m_a_n_d  is  invoked  after  the variable's value has  |
  3047.                been changed; it can write a new  value  into  the  |
  3048.                variable  to override the original value specified  |
  3049.                in the write operation.   To  implement  read-only  |
  3050.                variables,  _c_o_m_m_a_n_d  will  have to restore the old  |
  3051.                value of the variable.                              |
  3052.  
  3053.                While _c_o_m_m_a_n_d is executing during a read or  write  |
  3054.                trace, traces on the variable are temporarily dis-  |
  3055.                abled.  This means that reads and  writes  invoked  |
  3056.                by  _c_o_m_m_a_n_d  will occur directly, without invoking  |
  3057.                _c_o_m_m_a_n_d (or any other traces) again.                |
  3058.  
  3059.                When an unset trace is invoked, the  variable  has  |
  3060.                already  been deleted:  it will appear to be unde-  |
  3061.                fined with no traces.  If an unset occurs  because  |
  3062.                of  a  procedure  return,  then  the trace will be  |
  3063.                invoked in the variable context of  the  procedure  |
  3064.                being returned to:  the stack frame of the return-  |
  3065.                ing procedure will no longer  exist.   Traces  are  |
  3066.                not  disabled  during unset traces, so if an unset  |
  3067.                trace command creates a new trace and accesses the  |
  3068.                variable, the trace will be invoked.                |
  3069.  
  3070.                If there are multiple traces on  a  variable  they  |
  3071.                are  invoked  in  order  of  creation, most-recent  |
  3072.                first.  If one trace returns  an  error,  then  no  |
  3073.                further  traces  are invoked for the variable.  If  |
  3074.                an array element has a trace  set,  and  there  is  |
  3075.                also  a  trace  set  on  the array as a whole, the  |
  3076.                trace on the overall array is invoked  before  the  |
  3077.                one on the element.                                 |
  3078.  
  3079.                Once created, the trace remains in  effect  either  |
  3080.                until  the trace is removed with the ttrraaccee vvddeelleettee  |
  3081.                command described below,  until  the  variable  is  |
  3082.                unset,   or  until  the  interpreter  is  deleted.  |
  3083.                Unsetting an element  of  array  will  remove  any  |
  3084.                traces on that element, but will not remove traces  |
  3085.                on the overall array.                               |
  3086.  
  3087.                This command returns an empty string.               |
  3088.  
  3089.           ttrraaccee vvddeelleettee _n_a_m_e _o_p_s _c_o_m_m_a_n_d                                ||
  3090.                If  there is a trace set on variable _n_a_m_e with the  |
  3091.                operations and command given by _o_p_s  and  _c_o_m_m_a_n_d,  |
  3092.                then  the  trace  is removed, so that _c_o_m_m_a_n_d will  |
  3093.                never again be invoked.  Returns an empty string.   |
  3094.  
  3095.           ttrraaccee vviinnffoo _n_a_m_e                                              ||
  3096.  
  3097.  
  3098.  
  3099. Sprite v1.0                                                    47
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106. Tcl                   C Library Procedures                    Tcl
  3107.  
  3108.  
  3109.  
  3110.                Returns  a  list  containing  one element for each  |
  3111.                trace currently set on variable _n_a_m_e.   Each  ele-  |
  3112.                ment  of  the list is itself a list containing two  |
  3113.                elements, which are the _o_p_s and _c_o_m_m_a_n_d associated  |
  3114.                with  the trace.  If _n_a_m_e doesn't exist or doesn't  |
  3115.                have any traces set, then the result of  the  com-  |
  3116.                mand will be an empty string.                       |
  3117.  
  3118.      uunnkknnoowwnn _c_m_d_N_a_m_e ?_a_r_g _a_r_g ...?                                      ||
  3119.           This command doesn't actually exist as part of Tcl, but  |
  3120.           Tcl will invoke it if it does exist.  If the Tcl inter-  |
  3121.           preter encounters a command name for which there is not  |
  3122.           a defined command, then Tcl checks for the existence of  |
  3123.           a  command named uunnkknnoowwnn.  If there is no such command,  |
  3124.           then the interpeter returns an error.  If  the  uunnkknnoowwnn  |
  3125.           command  exists, then it is invoked with arguments con-  |
  3126.           sisting of the fully-substituted name and arguments for  |
  3127.           the original non-existent command.  The uunnkknnoowwnn command  |
  3128.           typically does things like  searching  through  library  |
  3129.           directories  for  a  command  procedure  with  the name  |
  3130.           _c_m_d_N_a_m_e, or  expanding  abbreviated  command  names  to  |
  3131.           full-length,  or  automatically  executing unknown com-  |
  3132.           mands as UNIX sub-processes.  In some  cases  (such  as  |
  3133.           expanding abbreviations) uunnkknnoowwnn will change the origi-  |
  3134.           nal command slightly and  then  (re-)execute  it.   The  |
  3135.           result of the uunnkknnoowwnn command is used as the result for  |
  3136.           the original non-existent command.                       |
  3137.  
  3138.      uunnsseett _n_a_m_e ?_n_a_m_e _n_a_m_e ...?                                         ||
  3139.           Remove  one or more variables.  Each _n_a_m_e is a variable  |
  3140.           name, specified in any of the ways  acceptable  to  the  |
  3141.           sseett  command.   If  a  _n_a_m_e  refers to an element of an  |
  3142.           array, then that element is removed  without  affecting  |
  3143.           the  rest of the array.  If a _n_a_m_e consists of an array  |
  3144.           name with no parenthesized index, then the entire array  |
  3145.           is  deleted.  The uunnsseett command returns an empty string  |
  3146.           as result.  An error occurs if  any  of  the  variables  |
  3147.           doesn't exist.
  3148.  
  3149.      uupplleevveell ?_l_e_v_e_l? _c_o_m_m_a_n_d ?_c_o_m_m_a_n_d ...?
  3150.           All of the _c_o_m_m_a_n_d arguments  are  concatenated  as  if
  3151.           they  had  been  passed  to  ccoonnccaatt; the result is then
  3152.           evaluated in the variable context indicated  by  _l_e_v_e_l.
  3153.           UUpplleevveell  returns  the  result  of  that evaluation.  If
  3154.           _l_e_v_e_l is an integer, then it gives a distance  (up  the
  3155.           procedure  calling  stack) to move before executing the
  3156.           command.  If _l_e_v_e_l consists of ## followed by  a  number
  3157.           then  the  number  gives  an absolute level number.  If
  3158.           _l_e_v_e_l is omitted then it defaults to 11.   _L_e_v_e_l  cannot
  3159.           be  defaulted if the first _c_o_m_m_a_n_d argument starts with
  3160.           a digit or ##.  For example, suppose  that  procedure  aa
  3161.           was  invoked  from top-level, and that it called bb, and
  3162.  
  3163.  
  3164.  
  3165. Sprite v1.0                                                    48
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172. Tcl                   C Library Procedures                    Tcl
  3173.  
  3174.  
  3175.  
  3176.           that bb called cc.  Suppose that cc  invokes  the  uupplleevveell
  3177.           command.   If  _l_e_v_e_l  is  11 or ##22  or omitted, then the
  3178.           command will be executed in the variable context of  bb.
  3179.           If  _l_e_v_e_l  is 22 or ##11 then the command will be executed
  3180.           in the variable context of aa.  If _l_e_v_e_l is 33 or ##00 then
  3181.           the  command will be executed at top-level (only global
  3182.           variables will be visible).  The uupplleevveell command causes
  3183.           the  invoking procedure to disappear from the procedure
  3184.           calling stack while the command is being executed.   In
  3185.           the above example, suppose cc invokes the command
  3186.  
  3187.                uupplleevveell 11 {{sseett xx 4433;; dd}}
  3188.           where dd is another Tcl procedure.  The sseett command will
  3189.           modify  the  variable xx in bb's context, and dd will exe-
  3190.           cute at level 3, as if called from bb.  If  it  in  turn
  3191.           executes the command
  3192.  
  3193.                uupplleevveell {{sseett xx 4422}}
  3194.           then the sseett command will modify the same variable xx in
  3195.           bb's  context:  the procedure cc does not appear to be on
  3196.           the call stack when dd is executing.  The command ``iinnffoo
  3197.           lleevveell''  may be used to obtain the level of the current
  3198.           procedure.  UUpplleevveell makes it possible to implement  new
  3199.           control  constructs  as  Tcl  procedures  (for example,
  3200.           uupplleevveell could be used to implement the wwhhiillee  construct
  3201.           as a Tcl procedure).
  3202.  
  3203.      uuppvvaarr ?_l_e_v_e_l? _o_t_h_e_r_V_a_r _m_y_V_a_r ?_o_t_h_e_r_V_a_r _m_y_V_a_r ...?
  3204.           This command arranges for one or more  local  variables  |
  3205.           in  the  current  procedure to refer to variables in an  |
  3206.           enclosing procedure call or to global variables.  _L_e_v_e_l  |
  3207.           may  have  any  of  the forms permitted for the uupplleevveell  |
  3208.           command, and may be omitted if the first letter of  the  |
  3209.           first  _o_t_h_e_r_V_a_r  isn't ## or a digit (it defaults to 11).  |
  3210.           For each _o_t_h_e_r_V_a_r argument, uuppvvaarr makes the variable by  |
  3211.           that  name in the procedure frame given by _l_e_v_e_l (or at  |
  3212.           global level, if _l_e_v_e_l is ##00) accessible in the current  |
  3213.           procedure  by the name given in the corresponding _m_y_V_a_r  |
  3214.           argument.  The variable  named  by  _o_t_h_e_r_V_a_r  need  not  |
  3215.           exist  at the time of the call;  it will be created the  |
  3216.           first time _m_y_V_a_r is referenced, just like  an  ordinary  |
  3217.           variable.   UUppvvaarr  may only be invoked from within pro-  |
  3218.           cedures.  Neither _o_t_h_e_r_V_a_r or _m_y_V_a_r  may  refer  to  an  |
  3219.           element of an array.  UUppvvaarr returns an empty string.     |
  3220.  
  3221.           The uuppvvaarr  command  simplifies  the  implementation  of  |
  3222.           call-by-name procedure calling and also makes it easier  |
  3223.           to build new control constructs as Tcl procedures.  For  |
  3224.           example, consider the following procedure:               |
  3225.  
  3226.                pprroocc aadddd22 nnaammee {{                                    |
  3227.                    uuppvvaarr $$nnaammee xx                                   |
  3228.  
  3229.  
  3230.  
  3231. Sprite v1.0                                                    49
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238. Tcl                   C Library Procedures                    Tcl
  3239.  
  3240.  
  3241.  
  3242.                    sseett xx [[eexxpprr $$xx++22]]                               |
  3243.                }}                                                   |
  3244.           AAdddd22 is invoked with an argument giving the name  of  a  |
  3245.           variable,  and  it  adds two to the value of that vari-  |
  3246.           able.  Although aadddd22 could have been implemented  using  |
  3247.           uupplleevveell  instead  of  uuppvvaarr, uuppvvaarr makes it simpler for  |
  3248.           aadddd22 to access the variable in the  caller's  procedure  |
  3249.           frame.
  3250.  
  3251.      wwhhiillee _t_e_s_t _b_o_d_y
  3252.           The _w_h_i_l_e command evaluates _t_e_s_t as an  expression  (in  |
  3253.           the  same  way  that eexxpprr evaluates its argument).  The  |
  3254.           value of the expression must be numeric; if it is  non-  |
  3255.           zero  then  _b_o_d_y  is  executed by passing it to the Tcl  |
  3256.           interpreter.  Once _b_o_d_y has been executed then _t_e_s_t  is  |
  3257.           evaluated  again, and the process repeats until eventu-  |
  3258.           ally _t_e_s_t evaluates to a zero numeric value.   CCoonnttiinnuuee  |
  3259.           commands  may  be executed inside _b_o_d_y to terminate the  |
  3260.           current iteration of the loop, and bbrreeaakk  commands  may  |
  3261.           be  executed inside _b_o_d_y to cause immediate termination  |
  3262.           of the wwhhiillee command.  The wwhhiillee command always returns  |
  3263.           an empty string.
  3264.  
  3265.  
  3266. BBUUIILLTT--IINN VVAARRIIAABBLLEESS
  3267.      The following  global  variables  are  created  and  managed
  3268.      automatically by the Tcl library.  Except where noted below,
  3269.      these variables should normally be treated as  read-only  by
  3270.      application-specific code and by users.
  3271.  
  3272.      eennvv
  3273.           This variable is maintained by Tcl as  an  array  whose  |
  3274.           elements are the environment variables for the process.  |
  3275.           Reading  an  element  will  return  the  value  of  the  |
  3276.           corresponding environment variable.  Setting an element  |
  3277.           of the array will modify the corresponding  environment  |
  3278.           variable  or  create  a  new  one if it doesn't already  |
  3279.           exist.  Unsetting an element of  eennvv  will  remove  the  |
  3280.           corresponding environment variable.  Changes to the eennvv  |
  3281.           array will affect the environment passed to children by  |
  3282.           commands  like  eexxeecc.  If the entire eennvv array is unset  |
  3283.           then Tcl will stop monitoring eennvv accesses and will not  |
  3284.           update environment variables.                            |
  3285.  
  3286.      eerrrroorr--  |
  3287.           CCooddee                                                          ||
  3288.           After an error has occurred, this variable will be  set  |
  3289.           to  hold  additional  information  about the error in a  |
  3290.           form that is easy to process with programs.   eerrrroorrCCooddee  |
  3291.           consists  of a Tcl list with one or more elements.  The  |
  3292.           first element of the list identifies a general class of  |
  3293.           errors,  and  determines  the format of the rest of the  |
  3294.  
  3295.  
  3296.  
  3297. Sprite v1.0                                                    50
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304. Tcl                   C Library Procedures                    Tcl
  3305.  
  3306.  
  3307.  
  3308.           list.  The following formats for eerrrroorrCCooddee are used  by  |
  3309.           the  Tcl core; individual applications may define addi-  |
  3310.           tional formats.                                          |
  3311.  
  3312.           CCHHIILLDDKKIILLLLEEDD _p_i_d _s_i_g_N_a_m_e _m_s_g                                   ||
  3313.                This  format is used when a child process has been  |
  3314.                killed because of a signal.  The second element of  |
  3315.                eerrrroorrCCooddee  will  be  the  process's identifier (in  |
  3316.                decimal).  The third element will be the  symbolic  |
  3317.                name of the signal that caused the process to ter-  |
  3318.                minate; it will be  one  of  the  names  from  the  |
  3319.                include  file  signal.h,  such  as  SSIIGGPPIIPPEE.   The  |
  3320.                fourth element will be a short human-readable mes-  |
  3321.                sage  describing  the  signal,  such as ``write on  |
  3322.                pipe with no readers'' for SSIIGGPPIIPPEE.                 |
  3323.  
  3324.           CCHHIILLDDSSTTAATTUUSS _p_i_d _c_o_d_e                                          ||
  3325.                This  format  is  used  when  a  child process has  |
  3326.                exited with a non-zero exit  status.   The  second  |
  3327.                element  of  eerrrroorrCCooddee will be the process's iden-  |
  3328.                tifier (in decimal) and the third element will  be  |
  3329.                the  exit  code  returned  by the process (also in  |
  3330.                decimal).                                           |
  3331.  
  3332.           CCHHIILLDDSSUUSSPP _p_i_d _c_o_d_e                                            ||
  3333.                This  format is used when a child process has been  |
  3334.                suspended because of a signal.  The second element  |
  3335.                of  eerrrroorrCCooddee will be the process's identifier, in  |
  3336.                decimal.  The third element will be  the  symbolic  |
  3337.                name  of  the  signal  that  caused the process to  |
  3338.                suspend; this will be one of the  names  from  the  |
  3339.                include  file  signal.h,  such  as  SSIIGGTTTTIINN.   The  |
  3340.                fourth element will be a short human-readable mes-  |
  3341.                sage  describing  the signal, such as ``background  |
  3342.                tty read'' for SSIIGGTTTTIINN.                             |
  3343.  
  3344.           NNOONNEE                                                          ||
  3345.                This format is used for errors where no additional  |
  3346.                information is available for an error besides  the  |
  3347.                message  returned  with the error.  In these cases  |
  3348.                eerrrroorrCCooddee will consist of a list containing a sin-  |
  3349.                gle element whose contents are NNOONNEE.                |
  3350.  
  3351.           UUNNIIXX _e_r_r_N_a_m_e _m_s_g                                              ||
  3352.                If  the  first  element of eerrrroorrCCooddee is UUNNIIXX, then  |
  3353.                the error occurred during a UNIX kernel call.  The  |
  3354.                second  element  of the list will contain the sym-  |
  3355.                bolic name of the error  that  occurred,  such  as  |
  3356.                EENNOOEENNTT;  this will be one of the values defined in  |
  3357.                the include file errno.h.  The  third  element  of  |
  3358.                the   list   will   be  a  human-readable  message  |
  3359.                corresponding to _e_r_r_N_a_m_e, such as ``no  such  file  |
  3360.  
  3361.  
  3362.  
  3363. Sprite v1.0                                                    51
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370. Tcl                   C Library Procedures                    Tcl
  3371.  
  3372.  
  3373.  
  3374.                or directory'' for the EENNOOEENNTT case.                 |
  3375.  
  3376.           To set eerrrroorrCCooddee, applications should use library  pro-  |
  3377.           cedures  such as TTccll__SSeettEErrrroorrCCooddee and TTccll__UUnniixxEErrrroorr, or  |
  3378.           they may invoke the eerrrroorr command.   If  one  of  these  |
  3379.           methods hasn't been used, then the Tcl interpreter will  |
  3380.           reset the variable to NNOONNEE after the next error.         |
  3381.  
  3382.      eerrrroorrIInnffoo
  3383.           After an error has occurred, this string  will  contain
  3384.           one or more lines identifying the Tcl commands and pro-
  3385.           cedures that were being executed when the  most  recent
  3386.           error  occurred.  Its contents take the form of a stack
  3387.           trace showing the various nested Tcl commands that  had
  3388.           been invoked at the time of the error.
  3389.  
  3390.  
  3391. AAUUTTHHOORR
  3392.      John  Ousterhout,  University  of  California  at   Berkeley
  3393.      (ouster@sprite.berkeley.edu)
  3394.  
  3395.      Many people have contributed to Tcl in various ways, but the
  3396.      following people have made unusually large contributions:
  3397.  
  3398.      Bill Carpenter
  3399.      Peter Da Silva
  3400.      Mark Diekhans
  3401.      Karl Lehenbauer
  3402.      Mary Ann May-Pumphrey
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429. Sprite v1.0                                                    52
  3430.  
  3431.  
  3432.  
  3433.